• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationExcep

 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is a standalone application to test Ioc feature of spring, but I always got the following exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'customerService': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.cybelink.ioc.DataSource com.cybelink.ioc.CustomerService.dataSource; nested exception is java.lang.NoClassDefFoundError: org/apache/velocity/exception/VelocityException

the application has 3 class as follow (the customer class is not related and so not paste the source here):


Interface DataSource


Implementation class of interface DataSource

the applicationContext.xml is as follow

 
peter tong
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
after change the CustomerService class as follow, the program can run


But now if I change the constructor of class RelationalDataSource to non-default, like the following:


then the following error prompted


so if the bean has no default constructor, then how to pass constructor args using autowire annotation?
 
reply
    Bookmark Topic Watch Topic
  • New Topic