AspectJ没有编译

时间:2017-12-21 18:50:23

标签: java maven java-8 aspectj dropwizard

我正在尝试使用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
  • 多模块设置

1 个答案:

答案 0 :(得分:3)

  

[ERROR]错误消息:configure.incompatibleComplianceForSource in:org.aspectj.ajdt.ajc.messages

将通过添加

来修复
<complianceLevel>1.8</complianceLevel>

除了<source/>&amp; <target/>

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