2

I've managed to configure to spring to auto-detect my components using the @Autowire annotation. However the problem is that not all the components are being Auto wired.
Specifically My DAO's are being bound but my service objects aren't. I have to explicitly create a bean for my service object in the spring xml config file.

Any clue as to why this is happening?

4

1 回答 1

3

If spring is not complaining about anything but it's still not being wired, there are a few probable causes, from most to least likely:

  • The service implementation is missing the proper annotation; i.e @Component, @Controller, @Service or one of the other annotations.
  • If the implementation is not annotated it has to be present as an xml bean definition.
  • The classpath-scan you have set up in the xml file does not hit the service.
  • Your jar file with services is packed without directory structure.
于 2009-01-09T17:55:46.267 回答