This week's book giveaway is in the Java in General forum.
We're giving away four copies of Event Streams in Action and have Alexander Dean & Valentin Crettaz on-line!
See this thread for details.
Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

spring jdbctemplate with multple dao classes

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • 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: 86
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 86
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 80
  • Mark post as helpful
  • send pies
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!