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

因此,我从spring配置中删除了<context:load-time-weaver/>,并向pom.xml添加了AspectJ编译器。但是我不知道如何在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 plugin配置为include 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>

07-26 00:29