AspectJ无法在IntelliJ中的maven项目中工作

时间:2017-09-12 08:43:13

标签: java maven intellij-idea aspectj

我有使用aspectJ进行审核的maven项目。我正在使用Intellij的想法。这是我在pom文件中的插件配置:

<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.7</version>
                <configuration>
                    <showWeaveInfo>true</showWeaveInfo>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <Xlint>ignore</Xlint>
                    <complianceLevel>${java.version}</complianceLevel>
                    <encoding>UTF-8</encoding>
                    <verbose>true</verbose>
                </configuration>
                <executions>
                    <execution>
                        <!-- IMPORTANT -->
                        <phase>process-sources</phase>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjtools</artifactId>
                        <version>1.8.10</version>
                    </dependency>
                </dependencies>
</plugin>

当我清理包时,aspectJ插件说:

Join point 'method-execution(java.util.List com.test.getHistories(java.lang.String, java.lang.String))' in Type 'com.test.HistoryService' (HistoryService.java:18) advised by around advice from 'com.test.aspects.AuditLoggerAspect' (AuditLoggerAspect.java:88)

Join point 'method-execution(java.lang.String com.test.getString(int, java.lang.Object))' in Type 'com.test' (AspectTest.java:14) advised by around advice from 'com.test.AuditLoggerAspect' (AuditLoggerAspect.class(from AuditLoggerAspect.java))

此应用程序打包是WAR,我想在Weblogic上部署它。 当我部署它或运行测试时,方面不起作用。为什么呢?

我在Java App中测试了这个方面和maven插件配置,它运行良好。

1 个答案:

答案 0 :(得分:1)

当我清理并打包项目maven-compiler-plugin在aspectJ-compiler-plugin编译之后重新编译项目。所以删除了编译的方面。 我将以下配置添加到maven-compiler-plugin来解决它:

 <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <!-- IMPORTANT -->
                    <useIncrementalCompilation>false</useIncrementalCompilation>
                </configuration>
  </plugin>