Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Spring为JTA和JPA配置独立应用程序_Spring_Jpa - Fatal编程技术网

使用Spring为JTA和JPA配置独立应用程序

使用Spring为JTA和JPA配置独立应用程序,spring,jpa,Spring,Jpa,我有一个使用JPA的独立应用程序。我想按照本手册第13.5节的要求对其进行配置。当谈到解释configuration.xml文件中必须包含的内容时,手册的这一部分是零碎的。我已经解决了几个问题,但现在我被下面的异常阻止了,该异常抱怨LoadTimeWeaver,我在手册中指定了LoadTimeWeaver 下面是异常和我的配置文件 是否有人配置并运行了第13.5节中的示例 另外,手册中是否附有示例代码?那会有很大帮助 谢谢 线程“main”org.springframework.beans.fa

我有一个使用JPA的独立应用程序。我想按照本手册第13.5节的要求对其进行配置。当谈到解释configuration.xml文件中必须包含的内容时,手册的这一部分是零碎的。我已经解决了几个问题,但现在我被下面的异常阻止了,该异常抱怨LoadTimeWeaver,我在手册中指定了LoadTimeWeaver

下面是异常和我的配置文件

是否有人配置并运行了第13.5节中的示例

另外,手册中是否附有示例代码?那会有很大帮助

谢谢

线程“main”org.springframework.beans.factory.BeanCreationException中出现异常:创建名为“loadTimeWeaver”的bean时出错:bean初始化失败;嵌套异常为java.lang.IllegalStateException:ClassLoader[sun.misc.Launcher$AppClassLoader]未提供“addTransformer(ClassFileTransformer)”方法。指定自定义LoadTimeWeaver或使用Spring的代理启动Java虚拟机:-javaagent:Spring-agent.jar



您是否尝试过
-javaagent:spring agent.jar
,正如例外情况所示?而
[jta]
与此有什么关系?jta是spring中可用的Tx管理器之一。调用此事务管理而不是JTA可能更好。您是否尝试过
-javaagent:spring agent.jar
,正如异常情况所示?那么
[JTA]
与此有什么关系?JTA是spring中可用的Tx管理器之一。调用此事务管理而不是JTA可能更好。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop.xsd">

    <context:annotation-config/>

    <context:load-time-weaver/>
    <bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" >
        <property name="loadTimeWeaver">
                <bean class="org.springframework.instrument.classloading.ReflectiveLoadTimeWeaver"/>
          </property>
      </bean>

    <bean id="appraisalBusiness"  class="business.AppraisalBusiness">
    </bean>
    <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:eqg"/>
        <property name="username" value="eqg"/>
        <property name="password" value="eqg"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/>
    </bean>

    <aop:config>
        <aop:pointcut id="allServiceMethods" expression="execution(* business.*.*(..))"/>
        <aop:advisor advice-ref="defaultTransactionAdvice" pointcut-ref="allServiceMethods"/>
    </aop:config>

    <tx:advice id="defaultTransactionAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method
                    name="*"
                    isolation="DEFAULT"
                    propagation="REQUIRED"
                    no-rollback-for="java.lang.RuntimeException"
                    timeout="100"/>
            <tx:method
                    name="get*"
                    read-only="true"/>
        </tx:attributes>
    </tx:advice>

</beans>