|
很怪异,配置那里都没有错,bean里老是得不到值,打出的日志分析,sessionfactory已经创建了。
配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- Hibernate SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- hibernate configFile Location -->
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<!-- References all OR mapping files. -->
<property name="mappingDirectoryLocations">
<list>
<value>classpath:com/ziptimes/domain</value>
</list>
</property>
</bean>
<!-- Pass the sessionfactory to HibernateTemplat-->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- Pass the HibernateTemplat to DAO -->
<bean id="managerSupport" class="com.ziptimes.manager.ManagerSupport">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
</beans>
bean:
public class ManagerSupport extends HibernateDaoSupport {
public ManagerSupport() {
log.debug("获得注入的值:" + super.getHibernateTemplate());
}
} |
|