Java-AspectJ无法编译

我正在尝试使用metrics-aspectj库(https://github.com/astefanutti/metrics-aspectj)在我的Dropwizard应用程序中使用带注释的指标,但是在启动时看到以下异常:

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.8:compile (default) on project app: AJC compiler errors:
[ERROR] error Missing message: configure.incompatibleComplianceForSource in: org.aspectj.ajdt.ajc.messages
[ERROR] error no sources specified
[ERROR] abort AspectJ Compiler 1.8.7

这是我的pom文件中的内容:

<dependency>
  <groupId>io.astefanutti.metrics.aspectj</groupId>
  <artifactId>metrics-aspectj</artifactId>
  <version>1.2.0</version>
</dependency>
<dependency>
  <groupId>org.aspectj</groupId>
  <artifactId>aspectjrt</artifactId>
  <version>1.8.10</version>
</dependency>

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.8</version>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
      <aspectLibraries>
        <aspectLibrary>
          <groupId>io.astefanutti.metrics.aspectj</groupId>
          <artifactId>metrics-aspectj</artifactId>
        </aspectLibrary>
      </aspectLibraries>
    </configuration>
    <executions>
      <execution>
        <goals>
          <goal>compile</goal>
        </goals>
      </execution>
    </executions>
  </plugin>

应用详情

> Java 8
> Dropwizard
>多模块设置

解决方法:

[ERROR] error Missing message: configure.incompatibleComplianceForSource in: org.aspectj.ajdt.ajc.messages

将通过添加进行修复

<complianceLevel>1.8</complianceLevel>

除了< source /> & < target />

< complianceLevel />默认为1.5,< source /> 1.8不向后兼容1.5.

上一篇:Spring学习 之 AOP切面执行顺序的控制


下一篇:6.aop AspectJ