aspose file tools*
The moose likes Spring and the fly likes Autowired Issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Autowired Issue" Watch "Autowired Issue" New topic
Author

Autowired Issue

Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Good day and thanks for viewing my post.

I have got an issue with @Autowired not working from a tutorial I found here: http://viralpatel.net/blogs/spring3-mvc-hibernate-maven-tutorial-eclipse-example/. I have used Autowired before in another application, but for some reason, I cannot figure out why the heck it is not working in this application. If I'm using component-scan, do I still need to create the bean? I did add the beans, but it still did not work. Here is what I have, can you see something I am not (see below)?

Thanks for your help!

Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
<bean id="contactService" class="com.springhibernate.contact.service.ContactServiceImpl" />
<bean id="contactDAO" class="com.springhibernate.contact.dao.ContactDAOImpl" />


Problem is here, when you have made use of annotations, why are using above mappings in xml?

Please go through that explanations in that tutorial step by step and you will surely be able to wire service class into your controller which currently your code is deprived of.

Thanks,
Ashwini Kashyap | www.infocepts.com
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Hello Ashwini. I initially did not have those beans declared, but it didn't work. So, I added the beans and still it doesn't work. I did follow the tutorial and went through it several times trying to figure out why I keep getting the same ContactService error...no matter what I do. I spent two days trying to figure it out, so I'm out of ideas.
Ashwini Kashyap
Ranch Hand

Joined: Aug 30, 2012
Posts: 90
Ok.. But keep your xml without those mappings.
Also, why have you used @Configuration in controller class?

Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
The @Configuration was added in my attempt to correct the ContactService error; but it did not help. I have scoured the web looking for an answer and was hoping I would find the answer here.
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
For those who come across the same issue, I was missing @Component in my ContactController class.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Autowired Issue