问题描述
- spring 注入 dao,引用的时候为null
-
spring配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">default-autowire="no">
<bean id="IBdxmService" parent="baseTransactionProxy"> <property name="target"> <bean class="cn.com.ebidding.web.dljk.bdxm.service.impl.BdxmService"> <property name="dao" ref="IBdxmDao" /> </bean> </property> </bean> <bean id="IBdxmAuth" parent="baseTransactionProxy"> <property name="target"> <bean class="cn.com.ebidding.web.dljk.bdxm.auth.impl.BdxmAuth" singleton="false"> <property name="dao" ref="IBdxmDao" /> </bean> </property> </bean> <bean id="IBdxmBusiness" parent="baseTransactionProxy"> <property name="target"> <bean class="cn.com.ebidding.web.dljk.bdxm.business.impl.BdxmBusiness"> <property name="dao" ref="IBdxmDao" /> </bean> </property> </bean> <bean id="IBdxmValidate" parent="baseTransactionProxy"> <property name="target"> <bean class="cn.com.ebidding.web.dljk.bdxm.validate.impl.BdxmValidate"> <property name="dao" ref="IBdxmDao" /> </bean> </property> </bean> <bean id="IBdxmDao" class="cn.com.ebidding.web.dljk.bdxm.dao.impl.BdxmDao"> <property name="sessionFactory" ref="sessionFactory" /> </bean>
解决方案
http://www.oschina.net/question/366783_132939?sort=time&p=1
解决方案二:
配置文件中没看到往bdxmservice中注入dao这个属性
解决方案三:
你的spring中关于ISapDao的配置错误,你的class="cn.com.ebidding.web.wzjk.sap.dao.impl.SapDao">这个类是他的实现类吗?怎么看着像是接口类呢?
时间: 2025-01-19 13:59:04