java - 编译时编织配置

标签 java spring maven-2 aop aspectj

我正在尝试将加载时编织的方面转换为编译时编织的。

所以我删除了<context:load-time-weaver/>从我的 spring 配置中,并将aspectj编译器添加到我的 pom.xml 。但我不知道如何转换META-INF/aop.xml中的信息.

我里面有这样的东西:

<!DOCTYPE aspectj PUBLIC
        "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
    <weaver>
        <!-- only weave classes in this package -->
    </weaver>
    <aspects>
        <!-- use only this aspect for weaving -->
        <concrete-aspect name="MyAspect_" extends="hu.myAspect">
        <pointcut name="pointcut" expression="execution(public * javax.persistence.EntityManager.*(..)) || execution(public * hu..*.create(..))"/>
        </concrete-aspect>
    </aspects>
</aspectj>

最佳答案

在编译时编织中没有与 aop.xml 完全相同的内容,但您可以配置 AspectJ maven plugininclude and exclude certain aspects像这样

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.3</version>
    <configuration>
        <includes>
            <include>**/TransationAspect.java</include>
            <include>**/SecurityAspect.aj</include>
        </includes>
        <excludes>
            <exclude>**/logging/*.aj</exclude>
        </excludes>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

关于java - 编译时编织配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3767370/

相关文章:

java - 如何在按钮点击之间创建延迟(以防止按钮垃圾邮件)

java - 如何在自定义 Spring Data Rest Controller 中正确处理 POST?

Eclipse+Maven 编译问题

maven-2 - 将Web应用程序项目转换为maven项目并将相应的.classpath文件转换为pom.xml

java - 使用 MySQL hibernate : Auto-Generate Id : Equivalent of Sequence (Oracle) in MySQL

java - 当根pom具有两个或多个子模块共用的插件时,Maven循环引用

等效于 Javascript curl

java - Spring MVC validator : validate using current session object

java - 马文 : Where be the code?

java - 使用 SpringRestGraphDatabase API 在事务中工作