File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Changing System from xml to annotations -@Autowired not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Changing System from xml to annotations -@Autowired not working" Watch "Changing System from xml to annotations -@Autowired not working" New topic
Author

Changing System from xml to annotations -@Autowired not working

Tiago Farias
Greenhorn

Joined: Nov 06, 2008
Posts: 17
Hello,

I´m trying to change the way of bean injection in my system, from xml to annotations. Searching about it (even here in the forum), I was able to run my application without errors (I mean, stacktraces). The thing is, when I try to inject the bean, looks like the Spring Container. When I run some tests, I see that the object to be injected(a controller) is 'null'. I´ve tried so many things, with no success, so it seems something is missing. Below are my code and configurations. Oh, and right now I´m just trying to change a feature of the app, if it works, I´ll apply the changes to the rest of the app.


1.








Now my configurations(applicationContext.xml is divided in 2 parts, controladorContext.xml and daoContext.xml):




That´s it, I have no idea why that doesnt work. =/ Any help is much appreciated! =]

Thanks in advance!
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Is it just the top one that is not getting injected, and the two below it that also have Autowired are not.

I noticed the first one does not have an annotation at the class level, is there a <bean> tag in the xml for it to make it an actual Spring Bean that can then be autowired?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Changing System from xml to annotations -@Autowired not working
 
Similar Threads
dependency inject in web services
controller don't display view
DI is not working in my example.
Junit + ContextConfiguration
Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationExcep