• 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

spring jdbctemplate with multple dao classes

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

In my spring configuration file, I defined spring DataSource bean and JdbcTemplate bean as below..



When I run the app, it is throwing error below..



Below are my dao and service classes.

UserDaoImpl.java



UserDao.java



UserService.java




I believe there should be some problem in the configuration file. Is it because, I'm defining the data source as singleton, I'm getting the error? Can you please clarity?

Thanks in advance for your help!

 
Ranch Hand
Posts: 93
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you are autowiring twice with these lines:



and



try removing the 'autowire' annotation from the java code.
 
Tim Nachreiner
Ranch Hand
Posts: 93
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to follow the Spring convention of having your service class implement an interface.  You should rename UserService to UserServiceImpl and have it implement an interface called UserService.
 
santosh batta
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim. I verified that I'm not doing component scan to the dao layer. So, I removed the @Autowired and my code worked. Thanks again to figure this out.
 
I wasn't selected to go to mars. This tiny ad got in ahead of me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic