【问题标题】:AspectJ not working in maven project in IntelliJAspectJ 在 IntelliJ 的 maven 项目中不起作用
【发布时间】:2018-02-20 15:28:47
【问题描述】:

我有一个使用 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 插件配置,效果很好。

【问题讨论】:

    标签: java maven intellij-idea aspectj


    【解决方案1】:

    当我清理和打包项目时,maven-compiler-pluginaspectj-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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-18
      • 2019-05-19
      • 2018-05-31
      • 1970-01-01
      • 1970-01-01
      • 2017-07-04
      • 1970-01-01
      相关资源
      最近更新 更多