我的带有spring和hibernate的java项目,无法获取sessionFactory。当我使用它时,它一直为空。配置:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
</props>
</property>
</bean>
<bean id="test" class="test.Test">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>`
Test.java 的主要代码是
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public SessionFactory getSessionFacoty(){
return this.sessionFactory;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Test test = new Test();
System.out.println(test.sessionFactory);
}