简体   繁体   English

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

[英]Can't compile my javafx and selenium project due to google autoservice processor ("Unable to get public no-arg constructor")

I'm trying to compile my Instagram bot with maven.我正在尝试使用 maven 编译我的 Instagram 机器人。 It uses javafx for the interface and selenium for the automation, and I've been stuck with this error for a long time.它使用 javafx 作为接口,使用 selenium 作为自动化,我已经被这个错误困扰了很长时间。

When I try to do mvn clean javafx:jlink it shows me this error:当我尝试执行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

The only thing that I found about this issue is this: https://stackoverflow.com/a/36250332/15479657我发现关于这个问题的唯一一件事是: https://stackoverflow.com/a/36250332/15479657

I added what the answer suggested to my pom, but it doesn't seem to work我将答案建议添加到我的 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>

The post had a comment after the include saying <!--include dependencies required for LogMeCustomAnnotationProcessor --> Do I have to include Google AutoServiceProcessor depencencies?该帖子在包含后有评论说<!--include dependencies required for LogMeCustomAnnotationProcessor -->我是否必须包含 Google AutoServiceProcessor 依赖项? And how do I get them?我如何得到它们?

I've also tried to manually add like a dependency Google AutoServiceProcessor on my pom.xml but it doesn't work ( https://mvnrepository.com/artifact/com.google.auto.service/auto-service/1.0 )我也尝试在我的 pom.xml 上手动添加依赖项 Google AutoServiceProcessor 但它不起作用( https://mvnrepository.com/artifact/com.google.auto.service/auto-service/1.0

What am I missing?我错过了什么? Thank you in advance先感谢您

Today I had a similar problem.今天我遇到了类似的问题。 The solution for me was to include the following into the maven-compiler-plugin configuration tag:我的解决方案是将以下内容包含到 maven-compiler-plugin 配置标签中:

<annotationProcessorPaths>
    <path>
      <groupId>com.google.auto.service</groupId>
      <artifactId>auto-service</artifactId>
      <version>${auto-service.version}</version>
    </path>
</annotationProcessorPaths>

You should replace ${auto-service.version} appropriately.您应该适当地替换 ${auto-service.version}。

So in the end it looked like:所以最后它看起来像:

<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