Spring 配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="objectDao" class="com.zh.epai.Dao.Item.ObjectDaoItem">
<property name="sessionFactory" ref="sessionFactory" />
<property name="objectDao" ref="objectDao"></property>
</bean>
<bean id="objectBiz" class="com.zh.epai.Biz.Impl.ObjectBizImpl">
<property name="objectDao" ref="objectDao"></property>
</bean>
<bean id="textDao" class="text.textObjectDao">
<property name="objectDao" ref="objectDao"></property>
</bean>
<bean id="wori" class="com.zh.epai.Biz.Impl.ObjectBizImpl">
<property name="objectDao" ref="objectDao"></property>
</bean>
</beans>
//后台代码
package com.zh.epai.Biz.Impl;import com.zh.epai.Biz.ObjectBiz;
import com.zh.epai.Dao.ObjectDao;
import com.zh.epai.entity.TUser;public class ObjectBizImpl implements ObjectBiz {
ObjectDao objectDao;
public ObjectDao getObjectDao() {
return objectDao;
} public void setObjectDao(ObjectDao objectDao) {
this.objectDao = objectDao;
} public int addObject(Object item) {
System.out.println(objectDao);
return objectDao.addObject(item);
}
}
问题:获取不到objectDao objectDao为null在线求救高手
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<bean id="objectDao" class="com.zh.epai.Dao.Item.ObjectDaoItem">
<property name="sessionFactory" ref="sessionFactory" />
<property name="objectDao" ref="objectDao"></property>
</bean>
<bean id="objectBiz" class="com.zh.epai.Biz.Impl.ObjectBizImpl">
<property name="objectDao" ref="objectDao"></property>
</bean>
<bean id="textDao" class="text.textObjectDao">
<property name="objectDao" ref="objectDao"></property>
</bean>
<bean id="wori" class="com.zh.epai.Biz.Impl.ObjectBizImpl">
<property name="objectDao" ref="objectDao"></property>
</bean>
</beans>
//后台代码
package com.zh.epai.Biz.Impl;import com.zh.epai.Biz.ObjectBiz;
import com.zh.epai.Dao.ObjectDao;
import com.zh.epai.entity.TUser;public class ObjectBizImpl implements ObjectBiz {
ObjectDao objectDao;
public ObjectDao getObjectDao() {
return objectDao;
} public void setObjectDao(ObjectDao objectDao) {
this.objectDao = objectDao;
} public int addObject(Object item) {
System.out.println(objectDao);
return objectDao.addObject(item);
}
}
问题:获取不到objectDao objectDao为null在线求救高手
解决方案 »
- 在线等!org.hibernate.TransientObjectException: object references an unsaved transie
- 项目上传到服务器运行时包错:SELECT command denied to user...
- 求能够使用的完整的ASP人力资源管理系统的源码(JSP或PHP也可以)
- struts2错误InvocationTargetException
- 关于j2sdk 1.4 和java EE 5 的问题
- WSAD发布Web Service问题
- java解析超大xml并插入数据库
- 推荐几本提升JAVA servlets的书籍
- 关于svn的问题
- 配置连接池错误
- 有没有做人力资源管理系统的大师
- 用hibernate封装自定义表单,怎样修改表名
<property name="sessionFactory" ref="sessionFactory" />
<property name="objectDao" ref="objectDao"> </property>
</bean>
是不是上面的有问题
<property name="sessionFactory" ref="sessionFactory" />
<property name="objectDao" ref="objectDao"> </property>
</bean>
你把自己注入到自己里面去,相当于自己把自抱起来.这样能行?
http://blog.csdn.net/wumingzu/archive/2009/05/07/4157177.aspx
http://blog.csdn.net/wumingzu/archive/2009/05/07/4157177.aspx