使用Spring Transaction Manager和Maven进行AspectJ加载时间的编织 [英] AspectJ Load Time Weaving with Spring Transaction Manager and Maven

查看:133
本文介绍了使用Spring Transaction Manager和Maven进行AspectJ加载时间的编织的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Spring的事务管理器启用加载时间编织,但是运气不好.目前,我只是试图在@Transactional方法中运行一个简单的em.persist(),但似乎没有运行事务,如通过TransactionSynchronizationManager.isActualTransactionActive()

I'm attempting to enable load time weaving with Spring's transaction manager but without too much luck. Currently I'm just trying to run a simple em.persist() in a @Transactional method but it does not appear to running a transaction as seen through: TransactionSynchronizationManager.isActualTransactionActive()

我的应用程序上下文文件包含:

My application context file contains :

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="TEST-pu"/>
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>
    <tx:annotation-driven transaction-manager="transactionManager" mode="aspectj" proxy-target-class="true"/>

我的pom.xml包含:

And my pom.xml contains:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-agent</artifactId>
    <version>2.5.4</version>
    <scope>provided</scope>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aspects</artifactId>
    <version>3.0.5.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>1.6.10</version>
</dependency>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.4</version>
    <configuration>
        <forkMode>once</forkMode>
        <argLine>
            -javaagent:${settings.localRepository}/org/springframework/spring-agent/2.5.4/spring-agent-2.5.4.jar
        </argLine>
        <useSystemClassloader>true</useSystemClassloader>
    </configuration>
</plugin> 

设置似乎有些问题,尽管我遇到了很多有关如何实现AspectJ/加载时间编织的示例,但它们似乎都在使用Eclipse插件,其中1)我试图避免使用任何种类的插件和2)我正在使用Intellij.任何帮助将不胜感激.

It would appear as if there is some issue with the setup and while I have come across quite a few examples of how to implement AspectJ / Load time weaving they all seem to be using Eclipse plugins which 1) I am trying to avoid using any sort of plugins and 2) I am using Intellij. Any help would be much appreciated.

谢谢.

推荐答案

您是否添加了

<context:load-time-weaver/>

要设置吗?

这篇关于使用Spring Transaction Manager和Maven进行AspectJ加载时间的编织的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆