Java org.springframework.beans.NotWritablePropertyException
我尝试使用Java org.springframework.beans.NotWritablePropertyException,java,spring,hibernate,spring-mvc,liferay,Java,Spring,Hibernate,Spring Mvc,Liferay,我尝试使用LocalSessionFactory运行一个spring项目,我得到一个空指针,因为我必须初始化类加载器。不管怎样,我在最后得到了这个例外 原因:org.springframework.beans.NotWritablePropertyException:bean类[org.springframework.orm.hibernate3.LocalSessionFactoryBean]的无效属性“sessionFactoryClassLoader”:bean属性“sessionFact
LocalSessionFactory
运行一个spring项目,我得到一个空指针,因为我必须初始化类加载器。不管怎样,我在最后得到了这个例外
原因:org.springframework.beans.NotWritablePropertyException:bean类[org.springframework.orm.hibernate3.LocalSessionFactoryBean]的无效属性“sessionFactoryClassLoader”:bean属性“sessionFactoryClassLoader”不可写或具有无效的setter方法。
setter的参数类型与getter的返回类型匹配吗
有什么建议吗
以下是实施方案:
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- Data Source Declaration -->
<bean id="DataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="jdbc:postgresql://localhost:5432/Database" />
<property name="username" value="postgres" />
<property name="password" value="password" />
</bean>
<!-- Session Factory Declaration -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="DataSource"></property>
<property name="mappingLocations">
<list>
<value>classpath:META-INF/products.xml
</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
</props>
</property>
<property name="sessionFactoryClassLoader" ref="portletClassLoader" />
</bean>
<!-- Enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="txManager"/>
<!-- Transaction Manager is defined -->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="portletClassLoader" class="com.liferay.portal.kernel.portlet.PortletClassLoaderUtil" factory-method="getClassLoader" />
</beans>
类路径:META-INF/products.xml
org.hibernate.dialogue.PostgreSqlDialogue
真的
更新
真的
真的
org.hibernate.cache.EhCacheProvider
顺便说一下,我想用另一个使用springFramework或hibernate库的类加载器替换com.liferay.portal.kernel.portlet.PortletClassLoaderUtil sessionFactoryClassLoader不是org.springframework.orm.hibernate3.LocalSessionFactoryBean的属性。
它可用于扩展的PortletSessionFactory实现。此异常非常明显。Spring正在尝试使用org.springframework.orm.hibernate3.LocalSessionFactoryBean类中不存在的setSessionFactoryClassLoader(..)方法设置sessionFactoryClassLoader。请发布您的配置!无法设置类加载器并继续使用org.springframework.orm.hibernate3.LocalSessionFactoryBean?@user3429578您可以尝试使用beanClassLoader属性。请点击此处: