gpt4 book ai didi

spring - 属性 'configurationClass'不可写或具有无效的setter方法。 setter 的参数类型

转载 作者:行者123 更新时间:2023-12-04 13:32:53 26 4
gpt4 key购买 nike

<?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:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">

<util:properties id="hibernateProperties" location="classpath:hibernate.properties" />

<bean id="usermanagementSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="usermanagementDataSource" />
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="hibernateProperties" ref="hibernateProperties" />
</bean>

<jee:jndi-lookup id="usermanagementDataSource" jndi-name="java:jboss/datasources/usermanagementDS" />

<bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager"
init-method="init" destroy-method="close">
<property name="forceShutdown" value="false" />
<property name ="startupTransactionService" value="true"/>
</bean>

<bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout" value="30" />
</bean>

<bean id="transactionManager"
class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager" ref="atomikosTransactionManager" />
<property name="userTransaction" ref="atomikosUserTransaction" />
</bean>

<bean id="User" class="com.ecom.data.access.model.User"/>
<bean id="myFactory" class="com.ecom.data.access.dao.MyFactory"/>

</beans>

我正在使用hibernate 4 spring 3 maven 3,我有此configuratiobn文件,在这里我使用的是本地 session 工厂,它可以正确编译,但是会出现错误
当我使用JBoss服务器进行部署时,服务器控制台显示错误“configurationClass”不可写或具有无效的setter方法。 setter的参数类型是否与getter的返回类型匹配?请帮助我解决这个问题

最佳答案

您的bean定义表明您正在尝试配置Hibernate 3,而不是Hibernate4。您可能遵循了错误的示例或教程。在Hibernate 4中,没有configurationClass属性。只需将其删除:

<bean id="usermanagementSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="usermanagementDataSource" />
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
<property name="hibernateProperties" ref="hibernateProperties" />
</bean>

使用Hibernate 4,您也不需要提供配置XML。您所要做的就是指定要扫描的软件包中的 @Entity类:
    <property name="packagesToScan" value="com.ecom.data.access.model" />

关于spring - 属性 'configurationClass'不可写或具有无效的setter方法。 setter 的参数类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17122299/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com