• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Autowired Issue

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<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
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok.. But keep your xml without those mappings.
Also, why have you used @Configuration in controller class?

 
Shannon Sims
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For those who come across the same issue, I was missing @Component in my ContactController class.
 
reply
    Bookmark Topic Watch Topic
  • New Topic