Hello,
I am quite new to Spring and think its a real cool framework, but i encountered some problems during testing my Services:
I've made a general BaseClass extending "AbstractTransactionalSpringContextTests" and overwrote the method getConfigLocations with my SpringConfig.xml. This worked fine for DAOSupport, aber but now i have this UnsatisfiedDependencyException i can not understand.
Full Stack Trace:
org.springframework.beans.factory.UnsatisfiedDepen dencyException: Error creating bean with name 'com.gerig.app.test.services.AddressServiceTest' defined in null:
Unsatisfied dependency expressed through bean property 'addressService': There are 2 beans of type [class com.gerig.app.services.base.AddressService] for autowire by type.
There should have been 1 to be able to autowire property 'addressService' of bean 'com.gerig.app.test.services.AddressServiceTest'.
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.autowireByType(Abstract AutowireCapableBeanFactory.java:800)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:720)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.autowireBeanProperties( AbstractAutowireCapableBeanFactory.java:188)
at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.setUp(AbstractDependencyInjec tionSpringContextTests.java:141)
at junit.framework.TestCase.runBare(TestCase.java:125 )
at junit.framework.TestResult$1.protect(TestResult.ja va:106)
at junit.framework.TestResult.runProtected(TestResult .java:124)
at junit.framework.TestResult.run(TestResult.java:109 )
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
But i only have one bean called addressService:
<bean id="addressService" parent="transactionInterceptorTemplate">
<property name="target">
<ref bean="addressServiceTarget"/>
</property>
</bean>
the AddressServiceTarget:
<bean id="addressServiceTarget" class="com.gerig.app.services.base.AddressService" >
<property name="addressDAO">
<ref bean="addressDAO"/>
</property>
<property name="lovService">
<ref bean="lovService"/>
</property>
<property name="zipCode2CityService">
<ref bean="zipCode2CityService"/>
</property>
</bean>
I donīt know the Problem. Is there any way to solve this Probem??
Thank you!


Reply With Quote