[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 564
  • Last Modified:

spring UnsatisfiedDependencyException

>>>In case of any ambiguity in ‘byType’ or ‘constructor’ mode, an UnsatisfiedDependencyException will be thrown.


I was reading above lines at
http://www.mkyong.com/spring/spring-auto-wiring-beans-in-xml/
I did not understand clearly. What is UnsatisfiedDependencyException. when do we get it. I usually see that in my application.
Any ideas, resources,sample code,links,  highly appreciated. thanks in advance.
0
gudii9
Asked:
gudii9
3 Solutions
 
Amitkumar PSr. ConsultantCommented:
Simiar answer for similar question :)

Please refer the API, it says "Exception thrown when a bean depends on other beans or simple properties that were not specified in the bean factory definition, although dependency checking was enabled."

Refer : http://static.springsource.org/spring/docs/2.0.5/api/org/springframework/beans/factory/UnsatisfiedDependencyException.html
0
 
objectsCommented:
Its just saying if it cannot determine which bean to autwire then it throws that exception
eg. if using byType and there are two beans of the required type. In this case it has no way to know what to use so it throws UnsatisfiedDependencyException
0
 
Sathish David Kumar NCommented:
Normally autowire is false in your bean creation in the applicationContext.xml file ...  its defaulty take it by no ....

so while your wiring you will mention that which class can be wiried ..

but if you use autowire=true meansthen you can use no, byName,byType,constructor,autodetct
while using this ur not correct wired means then you will get that error !!


Check the link for more reffrencess ... http://www.springindepth.com/book/in-depth-ioc-autowiring.html
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now