简体   繁体   中英

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. It uses javafx for the interface and selenium for the automation, and I've been stuck with this error for a long time.

When I try to do mvn clean javafx:jlink it shows me this error:

 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

I added what the answer suggested to my pom, but it doesn't seem to work

<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? 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 )

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:

<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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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