我使用构造函数参数使用Spring注入时出现此错误:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'testIdCreator': Unsatisfied dependency
expressed through constructor argument with index 0 of type
[IdCreatorDao]: : No matching bean of type [com.dao.IdCreatorDao
Bean定义:
<bean id="testIdCreator" class="com.utils.TestIdCreator">
<constructor-arg ref="mydDao"/>
</bean>
<bean id="mydDao" class="com.dao.idCreatorDAOImpl">
<constructor-arg ref="somedatasource" />
<constructor-arg value="${somedatasource.schema}" />
</bean>
Bean使用:
public class TestIdCreator{
private final IdCreatorDao idDao;
@Inject
public TestIdCreator(IdCreatorDao idDao) {
this.idDao= idDao;
}
}