不执行aspectJ编译器,因为项目不是支持Java类路径的包

Oh *_*oon 4 aspectj maven

我的aspectj类没有被编译,尽管它们用@Aspect注释并且驻留在.aj扩展文件中.

该项目是Maven JBoss AS 7 EAR Archetype.

[INFO] --- aspectj-maven-plugin:1.4:compile (default-cli) @ hms ---
[WARNING] Not executing aspectJ compiler as the project is not a Java classpath-capable package
[INFO] --- aspectj-maven-plugin:1.4:compile (default-cli) @ hms-ejb ---
[WARNING] bad version number found in C:\Users\Oh Chin Boon\.m2\repository\org\aspectj\aspectjrt\1.5.4\aspectjrt-1.5.4.jar expected 1.6.11 found 1.5.4
[WARNING] advice defined in sg.java.hms.aspect.AbstractLoggingAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in sg.java.hms.aspect.DefaultLoggingAspect has not been applied [Xlint:adviceDidNotMatch]
[WARNING] advice defined in sg.java.hms.aspect.AbstractLoggingAspect has not been applied [Xlint:adviceDidNotMatch]
Run Code Online (Sandbox Code Playgroud)

编辑:pom.xml片段

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.4</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
    </configuration>
    <executions>
        <execution>
            <phase>process-sources</phase>
            <goals>
                <goal>compile</goal>       <!-- use this goal to weave all your main classes -->
            </goals>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

And*_*erg 5

不知何故,你引用了aspectj 1.5.4,但你的源和目标级别是1.6.AspectJ 1.5.x仅针对Java 1.5.您需要明确指定AspectJ 1.6.这样的东西应该在你的依赖项部分工作:

<dependency>
  <groupId>org.aspectj</groupId>
  <artifactId>aspectjrt</artifactId>
  <version>1.6.12</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)