【发布时间】:2019-12-30 21:08:49
【问题描述】:
我正在尝试重现Using AspectJ annotations in maven project: weaving is not working 中的示例,其中给出了答案。特别是,现在我正在使用 Eclipse Photon,JDK 1.8 但没有成功。
我的最终 POM.XML 是:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>aspect-tutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.plugin.version>3.8.1</maven.compiler.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.5</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<!-- IMPORTANT -->
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- IMPORTANT -->
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<mainClass>com.pkg.MainApp</mainClass>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build></project>
我尝试使用 Eclipse(MainApp --> Run as...)和 Maven(pom.xml -->Run as --> Maven Build)运行,但没有进行编织。有什么想法吗?
非常感谢!碧儿
【问题讨论】:
-
乍一看,POM 看起来不错,它与我在另一个问题中的答案非常相似。我认为问题可能出在您的目录结构和代码中。最好的办法是在 GitHub 上发布你的整个项目(如果它很大,则简化为 MCVE)并分享一个链接,这样我就可以克隆和分析它。像这样我不能告诉你出了什么问题,我什至看不到你的应用程序和方面代码。 P.S.:您是否在 Eclipse 中安装了 AspectJ 开发工具(AJDT)?
-
感谢 Kriegaex。是的,如果我将项目转换为 AspectJ 项目,它就可以工作。但是,我对使用 travis CI 进行编织很感兴趣。在 Eclipse 中,编织是通过 AJDT 执行的,但我想在 travis 中执行编织。我在 GitHug (github.com/beperev/aspectjExample) 中有一个与 travis (travis-ci.com/beperev/aspectjExample) 连接的公共玩具示例。我可以看到两个测试都通过了,但“之前”建议中没有显示“Hello”消息。
-
你完全改变了问题的焦点。这是关于 Maven 和 AspectJ,而不是关于 Eclipse 或 Travis CI。如果您的 Maven 构建工作正常,那么一切都应该到位,因为您可以在 Eclipse 和 IntelliJ IDEA 等 IDE 中导入 Maven 项目,在 Travis CI 上运行 Maven 构建等。我看不出它为什么不能在那里工作。
标签: maven aop aspectj aspectj-maven-plugin