Win a copy of 97 Things Every Java Programmer Should Know 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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: 91
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: 91
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 no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic