繁体   English   中英

由于谷歌自动服务处理器,无法编译我的 javafx 和 selenium 项目(“无法获取公共无参数构造函数”)

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM