我处理一个使用@Autovalue注释的Maven项目,后来我不得不将Aspectj集成到其中。 pom.xml文件的相关部分在下面给出。
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
</dependency>
未在pom.xml中指定版本,并且正如我在mvn存储库中检查的那样,用于自动值的版本为 1.0-rc1 。
这是我添加到pom.xml中以集成Maven Aspectj插件的块。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.7</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/*.java</include>
</includes>
<showWeaveInfo>true</showWeaveInfo>
<source>1.8</source>
<target>1.8</target>
<Xlint>ignore</Xlint>
<complianceLevel>1.8</complianceLevel>
<encoding>UTF-8</encoding>
<verbose>false</verbose>
<aspectLibraries>
<aspectLibrary>
<groupId>com.cinglevue.veip</groupId>
<artifactId>veip-audit</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
</plugin>
使用的Aspectj版本为 1.8.2
一旦我对pom.xml进行了必要的更改,并使用mvn clean install进行了构建,就会收到如下的AJC编译错误
[INFO] --- aspectj-maven-plugin:1.7:compile (default) @ veip-web ---
[INFO] Showing AJC message detail for messages of types: [error, warning, fail]
[WARNING] incorrect classpath: /Users/shettiarachchi/.m2/repository/org/apache/jena/apache-jena-libs/2.11.1/apache-jena-libs-2.11.1.pom
<unknown source file>:<no line information>
[WARNING] Varargs methods should only override or be overridden by other varargs methods unlike ResourceBundleMessageSource.setBasenames(String[]) and AbstractResourceBasedMessageSource.setBasenames(String...)
/Users/shettiarachchi/virtuoso/veip/veip-web/src/main/java/com/cinglevue/veip/web/spring/ResourceBundleMessageSource.java:22
public void setBasenames(String[] basenames) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] The type AutoValue_HomeroomEventDto is already defined
/Users/shettiarachchi/virtuoso/veip/com/cinglevue/veip/web/connector/timetable/AutoValue_HomeroomEventDto.java:9
final class AutoValue_HomeroomEventDto extends HomeroomEventDto {
^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] The type AutoValue_SchoolTypeDto is already defined
/Users/shettiarachchi/virtuoso/veip/com/cinglevue/veip/web/connector/gradelevel/AutoValue_SchoolTypeDto.java:5
final class AutoValue_SchoolTypeDto extends SchoolTypeDto {
^^^^^^^^^^^^^^^^^^^^^^
然后,我在社区中对此进行了探索,并找到了这个线索 Bug-462782
按照他们的建议,我将自动值版本升级到1.0,但随后又出现另一个错误
java.lang.NoSuchMethodError: org.apache.velocity.runtime.parser.node.SimpleNode.getTemplateName()Ljava/lang/String;
[ERROR] at com.google.auto.value.processor.TemplateVars.toText(TemplateVars.java:116)
[ERROR] at com.google.auto.value.processor.AutoValueProcessor.processType(AutoValueProcessor.java:391)
我不太确定从这里开始做什么,如果有人可以帮助我,这是很棒的事情。