我具有以下构建配置:
父POM:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
<annotationProcessorPaths>
<path>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<version>1.6.5</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
其中一个子项目包含以下内容:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.24</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
当我运行此配置时,我不断得到一个org.apache.maven.lifecycle.LifecycleExecutionException
:
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project imgn: Fatal error compiling
...
Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling
...
Caused by: org.codehaus.plexus.compiler.CompilerException: java.lang.NoSuchMethodError: com.squareup.javapoet.ClassName.withoutAnnotations()Lcom/squareup/javapoet/ClassName;
...
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: com.squareup.javapoet.ClassName.withoutAnnotations()Lcom/squareup/javapoet/ClassName;
...
Caused by: java.lang.NoSuchMethodError: com.squareup.javapoet.ClassName.withoutAnnotations()Lcom/squareup/javapoet/ClassName;
at dagger.internal.codegen.langmodel.DaggerElements.getTypeElement(DaggerElements.java:105)
at dagger.internal.codegen.InjectBindingRegistryImpl$BindingsCollection.shouldGenerateBinding(InjectBindingRegistryImpl.java:134)
...
[当我检查这些工件的依赖性时,com.google.auto.value:auto-value:1.6.5
(after checking parents)取决于com.squareup:javapoet:1.9.0
,而com.google.dagger:dagger-compiler:2.24
取决于com.squareup:javapoet:1.11.1
。
当我检查signature of ClassName::withoutAnnotation
in com:squareup:javapoet:1.11.1
为ClassName::withoutAnnotation
时。
com:squareup:javapoet:1.11.1
是public ClassName withoutAnnotations()
。
所以确实存在冲突。
如果是正常的依赖项,我知道会使用signature of ClassName::withoutAnnotation
in com:squareup:javapoet:1.9.0
标记,但是在这种情况下,如果添加此类标记,则会出现以下问题:ClassName::withoutAnnotation
。
那么我该如何解决com:squareup:javapoet:1.9.0
中的此类冲突?