[英]Can't compile my javafx and selenium project due to google autoservice processor ("Unable to get public no-arg constructor")
我正在嘗試使用 maven 編譯我的 Instagram 機器人。 它使用 javafx 作為接口,使用 selenium 作為自動化,我已經被這個錯誤困擾了很長時間。
當我嘗試執行mvn clean javafx:jlink
時,它向我顯示此錯誤:
Failed to execute goal org.openjfx:javafx-maven-plugin:0.0.3:jlink (default-cli) on project igbot: Error: Unable to execute mojo: Compilation failure
[ERROR] Bad service configuration file, or exception thrown while constructing Processor object: javax.annotation.processing.Processor: com.google.auto.service.processor.AutoServiceProcessor Unable to get public no-arg constructor
我發現關於這個問題的唯一一件事是: https://stackoverflow.com/a/36250332/15479657
我將答案建議添加到我的 pom 中,但它似乎不起作用
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<compilerArgument>-proc:none</compilerArgument>
<includes>
<include>com/google/auto/service/processor/AutoServiceProcessor.java</include>
</includes>
</configuration>
</execution>
<execution>
<id>compile-project</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
該帖子在包含后有評論說<!--include dependencies required for LogMeCustomAnnotationProcessor -->
我是否必須包含 Google AutoServiceProcessor 依賴項? 我如何得到它們?
我也嘗試在我的 pom.xml 上手動添加依賴項 Google AutoServiceProcessor 但它不起作用( https://mvnrepository.com/artifact/com.google.auto.service/auto-service/1.0 )
我錯過了什么? 先感謝您
今天我遇到了類似的問題。 我的解決方案是將以下內容包含到 maven-compiler-plugin 配置標簽中:
<annotationProcessorPaths>
<path>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>${auto-service.version}</version>
</path>
</annotationProcessorPaths>
您應該適當地替換 ${auto-service.version}。
所以最后它看起來像:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>com.google.auto.service</groupId>
<artifactId>auto-service</artifactId>
<version>1.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.