Hello,
I'm getting an error in my unit test setup. It's telling me:The problem is that I'm not using autowiring.Code:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'test.com.cirqular.cortrac.scheduledmail.HibernateCortracNewsEmailTests' defined in null: Unsatisfied dependency expressed through bean property 'cortracNewsDao': There are 2 beans of type [interface com.cirqular.cortrac.scheduledmail.CortracNewsDao] for autowire by type. There should have been 1 to be able to autowire property 'cortracNewsDao' of bean 'test.com.cirqular.cortrac.scheduledmail.HibernateCortracNewsEmailTests'. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:800) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:720) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:188) at .....
here is my testing config:
and the relavent other code:Code:<bean id="testCortracNewsDao" class="test.com.cirqular.cortrac.scheduledmail.HibernateCortracNewsEmailTests"> <property name="cortracNewsDao" ref="txCortracNewsDao"/> </bean>
Now I do in fact have two beans of Type: CortracNewsDao (defined above)Code:<bean id="txCortracNewsDao" parent="txProxyTemplate"> <property name="target"> <bean id="cortracNewsDao" class="com.cirqular.cortrac.scheduledmail.CortracNewsDaoHibernate"> <property name="sessionFactory" ref="sessionFactory"/> <property name="xslTransformUtil" ref="emailDaileyXsl"/> <property name="subject" value="CorTrac News"/> <property name="to"> <list> <value>jroberts@cirqular.com</value> </list> </property> <property name="from" value="${mail.fromAddress}"/> <property name="buildingGroupId" value="3"/> <property name="movementRangeHours" value="24"/> <property name="hasAccessToDa" value="true"/> <property name="levelIntervalDays" value="7"/> <property name="points" value="75"/> <property name="incidentRangeHours" value="24"/> <property name="scheduleRangeHours" value="24"/> <property name="maxMinutesLate" value="15"/> </bean> </property> </bean> <!-- same as cortracNewsDao, but only has access to work release --> <bean id="txCortracNewsWrDao" parent="txProxyTemplate"> <property name="target"> <bean id="cortracNewsWrDao" class="com.cirqular.cortrac.scheduledmail.CortracNewsDaoHibernate"> <property name="sessionFactory" ref="sessionFactory"/> <property name="xslTransformUtil" ref="emailDaileyXsl"/> <property name="subject" value="CorTrac News"/> <property name="to"> <list> <value>jroberts@cirqular.com</value> </list> </property> <property name="from" value="${mail.fromAddress}"/> <property name="buildingGroupId" value="3"/> <property name="movementRangeHours" value="24"/> <property name="hasAccessToDa" value="false"/> <property name="levelIntervalDays" value="7"/> <property name="points" value="75"/> <property name="incidentRangeHours" value="24"/> <property name="scheduleRangeHours" value="24"/> <property name="maxMinutesLate" value="15"/> </bean> </property> </bean>
But since am specifying ref="txCortracNewsDao", why does that matter?
argh


Reply With Quote