這是我的工具的Java文件:Bean屬性'sessionFactory'不可寫或具有無效的setter方法。
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: Invalid property 'sessionFactory' of bean class [com.chrysler.Utilities.HibernateUtil]: Bean property 'sessionFactory' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
謝謝阿卜杜拉。現在工作。 – user2160534 2013-04-09 10:56:20
現在我得到下面的一段代碼相同的錯誤:ContactController.java: public ModelAndView listContacts(){ 返回新的ModelAndView(「contact」,「contact」,contactService.listContact()); } 我收到以下錯誤代碼: org.springframework.beans.NotReadablePropertyException:bean類的無效屬性'firstName'[java.util.ArrayList]:Bean屬性'firstName'不可讀或具有無效的getter方法:getter的返回類型是否與setter的參數類型相匹配? – user2160534 2013-04-09 11:20:51