配置文件里写入了包检索
<context:component-scan base-package="com.test.rf.dao,com.test.rf.service" />在dao实现类上使用@Repository,启动TOMCAT报错
@Repository
public class ColorConfigureDao extends SqlMapClientDaoSupport implements IDataMoniterDao{
}
错误信息如下.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataMoniterDao' defined in file [C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\test\WEB-INF\classes\com\test\rf\dao\DataMoniterDao.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlMapClient' is required
在配置信息里面配置这个dao就不出错了,为啥注入就不好用呢,@Repository没有效果配置信息里加上这句话就没问题了<bean id="DataMoniter" class="com.lamiu.rf.dao.DataMoniterDao">
<property name="sqlMapClientTemplate">
<ref bean="sqlMapClientTemplate" />
</property>
</bean>
<context:component-scan base-package="com.test.rf.dao,com.test.rf.service" />在dao实现类上使用@Repository,启动TOMCAT报错
@Repository
public class ColorConfigureDao extends SqlMapClientDaoSupport implements IDataMoniterDao{
}
错误信息如下.org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataMoniterDao' defined in file [C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\test\WEB-INF\classes\com\test\rf\dao\DataMoniterDao.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlMapClient' is required
在配置信息里面配置这个dao就不出错了,为啥注入就不好用呢,@Repository没有效果配置信息里加上这句话就没问题了<bean id="DataMoniter" class="com.lamiu.rf.dao.DataMoniterDao">
<property name="sqlMapClientTemplate">
<ref bean="sqlMapClientTemplate" />
</property>
</bean>
你加上注解后,spring就会管理这个类,而这类,里的init方法需要一个sqlMapClient属性,你应该在这类里,注入sqlMapClient
com\test\rf\dao\DataMoniterDao.class
那请问这种情况我正常应该怎么处理 ?如果还要使用@Repository的话
<bean id="sqlMapClientDaoSupport" class="xxxx">
<property name="sqlMapClientTemplate" ref="">
</bean>
试试这个。好像还有其他的方法。但是我不记得了。你看这个行得通不