Spring - an unsatisfied dependency expressed through an object property

When I try to inject dao into the unit test class using spring, I get the following error.

UnitTest.DataAccess.FruitDaoTest.GetAllVitaminC:
SetUp : Spring.Objects.Factory.UnsatisfiedDependencyException : Error creating object with name 'FruitDaoTest' : Unsatisfied dependency expressed through object property 'FruitDao': Set this property value or disable dependency checking for this object.

Here is the corresponding segment of my spring configuration file:

<db:provider
    id="DbProvider"
    provider="SqlServer-2.0"
    connectionString="Data Source=stuff.group.stuff;Initial Catalog=zing;User ID=Marve; Password=stinky" />

<object id="transactionManager" type="Spring.Data.Core.AdoPlatformTransactionManager, Spring.Data">
  <property name="DbProvider" ref="DbProvider" />
</object>
<object id="FruitDao" type="FruitBasket.DataAccess.FruitDao, FruitBasket">
  <property name="DbProvider" ref="DbProvider"/>
  <property name="user" value="apple" />
  <property name="pass" value="orange" />
  <property name="server" value="pear" />
</object>

I am not very familiar with spring, so I am not sure if the problem is here. Any ideas?

+3
source share
1 answer

It seems your test does not use the context in which you defined your FruitDao bean, thereby preventing it from auto-negotiating ... Check the GetContext / ConfigLocations methods to make sure that you are loading the expected XML files.

+2
source

All Articles