这是我的实用程序 java 文件:
public class HibernateUtil {
private static SessionFactory sessionFactory = null;
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static void setSessionFactory(SessionFactory sessionFactory) {
HibernateUtil.sessionFactory = sessionFactory;
}
}
Spring-servlet.xml:
<bean id="HibernateUtil" class="com.chrysler.Utilities.HibernateUtil">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>/WEB-INF/hibernate.cfg.xml</value>
</property>
</bean>
当我运行它时,我收到以下错误:
org.springframework.beans.NotWritablePropertyException:bean 类 [com.chrysler.Utilities.HibernateUtil] 的无效属性“sessionFactory”:bean 属性“sessionFactory”不可写或具有无效的 setter 方法。setter 的参数类型是否与 getter 的返回类型匹配?