java - 无法获取公共(public)无参数构造函数

标签 java eclipse maven

最近我导入了Paho MQTT Spy project进入 Eclipse。导入结束时出现错误:

building has encouted a problem. An internal error occured during: "Build"

An internal error occurred during: "Building".
com.sun.tools.xjc.Plugin: com.sun.tools.xjc.addon.accessors.PluginImpl Unable to get public no-arg constructor

为什么我收到此消息?它意味着什么?如何修复它?

我使用的是 Java 13.0.1

我尝试使用 Maven 构建 mqtt-spy 项目并遇到相同的错误。

我将以下依赖项添加到 pom.xml

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.2.11</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-core</artifactId>
    <version>2.2.11</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.2.11</version>
</dependency>
<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1.1</version>
</dependency>

现在 pom.xml 如下所示:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.eclipse.paho.mqttspy</groupId>
    <artifactId>mqtt-spy</artifactId>
    <version>1.0.1-beta</version>
    <packaging>jar</packaging>

    <name>mqtt-spy</name>
    <url>https://github.com/eclipse/paho.mqtt-spy</url>

    <scm>
        <connection>scm:git:../.git</connection>
        <url>../.git</url>
    </scm>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.build.number>${buildNumber}</project.build.number>

        <timestamp>${maven.build.timestamp}</timestamp>
        <maven.build.timestamp.format>yyyy</maven.build.timestamp.format>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>

        <jaxb2.plugin.version>0.12.1</jaxb2.plugin.version>
        <jaxb2.basics.version>0.11.1</jaxb2.basics.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx</artifactId>
            <version>11</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.eclipse.paho.mqttspy</groupId>
            <artifactId>spy-common</artifactId>
            <version>1.0.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>maven-jaxb2-plugin</artifactId>
                    <groupId>org.jvnet.jaxb2.maven2</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.eclipse.paho.mqttspy</groupId>
            <artifactId>spy-common-ui</artifactId>
            <version>1.0.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>maven-jaxb2-plugin</artifactId>
                    <groupId>org.jvnet.jaxb2.maven2</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.eclipse.paho.mqttspy</groupId>
            <artifactId>mqtt-spy-common</artifactId>
            <version>1.0.1</version>
            <exclusions>
                <exclusion>
                    <artifactId>maven-jaxb2-plugin</artifactId>
                    <groupId>org.jvnet.jaxb2.maven2</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-artifact</artifactId>
            <version>3.0</version>
        </dependency>

        <!--=== TEST === -->

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>2.1_3</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jmock</groupId>
            <artifactId>jmock-legacy</artifactId>
            <version>2.5.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.objenesis</groupId>
            <artifactId>objenesis</artifactId>
            <version>1.0</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>

        <finalName>${project.artifactId}-${project.version}-b${buildNumber}</finalName>

        <!-- Populate version number in the properties file -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/mqtt-spy.properties</include>
                </includes>
            </resource>

            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>**/mqtt-spy.properties</exclude>
                </excludes>
            </resource>

        </resources>

        <plugins>

            <!-- Exclude files -->
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <id>package-client</id>
                        <phase>package</phase>
                        <configuration>
                            <classifier>exclusions</classifier>
                            <excludes>
                                <exclude>**/log4j.properties</exclude>
                            </excludes>
                        </configuration>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Create a runnable jar with all dependencies -->
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>pl.baczkowicz.mqttspy.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- Generate build number -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.3</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <doCheck>true</doCheck>
                    <doUpdate>true</doUpdate>
                    <buildNumberPropertiesFileLocation>buildNumber.properties</buildNumberPropertiesFileLocation>
                    <format>{0,number,###}</format>
                    <items>
                        <item>buildNumber</item>
                    </items>
                </configuration>
            </plugin>

            <!-- Generate JAXB clases -->
            <plugin>
                <groupId>org.jvnet.jaxb2_commons</groupId>
                <artifactId>jaxb2-basics</artifactId>
                <version>${jaxb2.basics.version}</version>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>${jaxb2.plugin.version}</version>
                <executions>
                    <execution>
                        <id>configuration</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <locale>en</locale>
                            <schemaDirectory>src/main/resources/</schemaDirectory>
                            <schemaIncludes>
                                <include>mqtt-spy-configuration.xsd</include>
                            </schemaIncludes>

                            <!-- Default to the schemaDirectory -->
                            <bindingDirectory>src/main/resources</bindingDirectory>
                            <bindingIncludes>
                                <include>**/mqtt-spy-configuration-bindings.xjb</include>
                            </bindingIncludes>

                            <generateDirectory>src/main/java/</generateDirectory>
                            <generatePackage>pl.baczkowicz.mqttspy.configuration.generated</generatePackage>
                            <removeOldOutput>false</removeOldOutput>

                            <strict>false</strict>
                            <catalogs>
                                <catalog>
                                    <dependencyResource>
                                        <groupId>org.eclipse.paho.mqttspy</groupId>
                                        <artifactId>mqtt-spy-common</artifactId>
                                        <resource>mqtt-spy-common.catalog</resource>
                                    </dependencyResource>
                                </catalog>
                                <catalog>
                                    <dependencyResource>
                                        <groupId>org.eclipse.paho.mqttspy</groupId>
                                        <artifactId>spy-common</artifactId>
                                        <resource>spy-common.catalog</resource>
                                    </dependencyResource>
                                </catalog>
                            </catalogs>

                            <episode>true</episode>
                            <!-- <episodeFile>src/main/java/META-INF/mqtt-spy-configuration.episode</episodeFile> -->

                            <episodes>
                                <episode>
                                    <groupId>org.eclipse.paho.mqttspy</groupId>
                                    <artifactId>mqtt-spy-common</artifactId>
                                </episode>
                                <episode>
                                    <groupId>org.eclipse.paho.mqttspy</groupId>
                                    <artifactId>spy-common</artifactId>
                                </episode>
                            </episodes>

                            <args>
                                <arg>-XtoString</arg>
                                <arg>-Xequals</arg>
                                <arg>-XhashCode</arg>
                                <arg>-Xcopyable</arg>
                                <arg>-Xvalue-constructor</arg>
                            </args>
                            <plugins>
                                <plugin>
                                    <groupId>org.jvnet.jaxb2_commons</groupId>
                                    <artifactId>jaxb2-basics</artifactId>
                                    <version>${jaxb2.basics.version}</version>
                                </plugin>
                            </plugins>
                        </configuration>
                    </execution>

                    <execution>
                        <id>stats</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <locale>en</locale>
                            <schemaDirectory>src/main/resources/</schemaDirectory>
                            <schemaIncludes>
                                <include>mqtt-spy-stats.xsd</include>

                            </schemaIncludes>

                            <!-- Default to the schemaDirectory -->
                            <bindingDirectory>src/main/resources</bindingDirectory>
                            <bindingIncludes>
                                <include>**/mqtt-spy-stats-bindings.xjb</include>
                            </bindingIncludes>

                            <generateDirectory>src/main/java/</generateDirectory>
                            <generatePackage>pl.baczkowicz.mqttspy.stats.generated</generatePackage>
                            <removeOldOutput>false</removeOldOutput>

                            <episode>false</episode>
                            <!-- <episodeFile>src/main/java/META-INF/mqtt-spy-stats.episode</episodeFile> -->

                            <args>
                                <arg>-XtoString</arg>
                                <arg>-Xequals</arg>
                                <arg>-XhashCode</arg>
                                <arg>-Xcopyable</arg>
                            </args>
                            <plugins>
                                <plugin>
                                    <groupId>org.jvnet.jaxb2_commons</groupId>
                                    <artifactId>jaxb2-basics</artifactId>
                                    <version>${jaxb2.basics.version}</version>
                                </plugin>
                            </plugins>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.jvnet.jaxb2_commons</groupId>
                        <artifactId>jaxb2-value-constructor</artifactId>
                        <version>3.0</version>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>replacer</artifactId>
                <version>1.5.3</version>
                <executions>
                    <execution>
                        <id>replace</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>replace</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <basedir>${basedir}/src/main/java</basedir>
                    <includes>
                        <include>pl/baczkowicz/mqttspy/configuration/generated/**/*.java</include>
                        <include>pl/baczkowicz/mqttspy/stats/generated/**/*.java</include>
                    </includes>
                    <replacements>
                        <replacement>
                            <token>//${line.separator}// This file was generated by the
                                JavaTM</token>
                            <value>//
                                // Copyright (c) ${maven.build.timestamp} Kamil Baczkowicz
                                //
                                // CSOFF: a.*
                                // This file was generated by the JavaTM</value>
                        </replacement>
                        <replacement>
                            <token>^ \*/</token>
                            <value> */
                                @SuppressWarnings("all")</value>
                        </replacement>
                        <replacement>
                            <token>^// Generated on.*$</token>
                            <value>// Timestamp removed by maven-replacer-plugin to avoid
                                detecting changes - see the project POM for details</value>
                        </replacement>
                    </replacements>
                    <regex>true</regex>
                    <quiet>false</quiet>
                    <regexFlags>
                        <regexFlag>MULTILINE</regexFlag>
                    </regexFlags>
                </configuration>
            </plugin>

        </plugins>

    </build>

</project>

Maven 给出错误:

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.eclipse.paho.mqttspy:mqtt-spy:jar:1.0.1-beta
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 162, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] -----------------< org.eclipse.paho.mqttspy:mqtt-spy >------------------
[INFO] Building mqtt-spy 1.0.1-beta
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.sun.xml.bind:jaxb-core:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.sun.xml.bind:jaxb-impl:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.eclipse.paho.mqttspy:spy-common:jar:1.0.1 is missing, no dependency information available
[WARNING] The POM for org.eclipse.paho.mqttspy:spy-common-ui:jar:1.0.1 is missing, no dependency information available
[WARNING] The POM for org.eclipse.paho.mqttspy:mqtt-spy-common:jar:1.0.1 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.384 s
[INFO] Finished at: 2020-01-08T16:10:33+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project mqtt-spy: Could not resolve dependencies for project org.eclipse.paho.mqttspy:mqtt-spy:jar:1.0.1-beta: The following artifacts could not be resolved: org.eclipse.paho.mqttspy:spy-common:jar:1.0.1, org.eclipse.paho.mqttspy:spy-common-ui:jar:1.0.1, org.eclipse.paho.mqttspy:mqtt-spy-common:jar:1.0.1: Failure to find org.eclipse.paho.mqttspy:spy-common:jar:1.0.1 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

更新

Java 8 解决了问题,但我仍在尝试让 java 13 能够使用它。

尝试使用下面定义的 pom.xml 构建非常根的项目。 pom.xml 现在包含所需的 javax 依赖项。

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 

    <modelVersion>4.0.0</modelVersion> 

    <name>mqtt-spy project</name> 
    <groupId>pl.baczkowicz.mqttspy</groupId>
    <artifactId>mqtt-spy-pom</artifactId>

    <packaging>pom</packaging> 
    <version>0.0.1-SNAPSHOT</version> 

    <properties>
        <main.basedir>${project.basedir}</main.basedir>
    </properties>


    <dependencies>  
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.2.11</version>
        </dependency>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>activation</artifactId>
            <version>1.1.1</version>
        </dependency>

    </dependencies>

    <!-- Include all modules in correct order. --> 
    <modules> 
        <module>spy-common</module> 
        <module>spy-common-ui</module> 
        <module>mqtt-spy-common</module> 
        <module>mqtt-spy-daemon</module>
        <module>mqtt-spy</module>  
    </modules> 

</project> 

遇到同样的错误:

[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.eclipse.paho.mqttspy:mqtt-spy-daemon:jar:1.0.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 113, column 15
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.eclipse.paho.mqttspy:mqtt-spy:jar:1.0.1-beta
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 162, column 12
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] spy-common                                                         [jar]
[INFO] spy-common-ui                                                      [jar]
[INFO] mqtt-spy-common                                                    [jar]
[INFO] mqtt-spy-daemon                                                    [jar]
[INFO] mqtt-spy                                                           [jar]
[INFO] mqtt-spy project                                                   [pom]
[INFO]
[INFO] ----------------< org.eclipse.paho.mqttspy:spy-common >-----------------
[INFO] Building spy-common 1.0.1                                          [1/6]
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for com.sun.xml.bind:jaxb-impl:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.sun.xml.bind:jaxb-xjc:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.sun.xml.bind:jaxb-core:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-jaxb2-plugin:0.12.1:generate (spy-common) @ spy-common ---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] spy-common 1.0.1 ................................... FAILURE [  0.737 s]
[INFO] spy-common-ui 1.0.1 ................................ SKIPPED
[INFO] mqtt-spy-common 1.0.1 .............................. SKIPPED
[INFO] mqtt-spy-daemon 1.0.0 .............................. SKIPPED
[INFO] mqtt-spy 1.0.1-beta ................................ SKIPPED
[INFO] mqtt-spy project 0.0.1-SNAPSHOT .................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.910 s
[INFO] Finished at: 2020-01-08T20:05:25+02:00
[INFO] ------------------------------------------------------------------------

......

---------------------------------------------------
Exception in thread "main" java.util.ServiceConfigurationError: com.sun.tools.xjc.Plugin: com.sun.tools.xjc.addon.accessors.PluginImpl Unable to get public no-arg constructor
        at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:583)
        at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:674)
        at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1233)
        at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1265)
        at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1300)
        at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1385)
        at com.sun.tools.xjc.Options.findServices(Options.java:960)
        at com.sun.tools.xjc.Options.getAllPlugins(Options.java:374)
        at com.sun.tools.xjc.Options.parseArgument(Options.java:688)
        at com.sun.tools.xjc.Options.parseArguments(Options.java:812)
        at org.jvnet.mjiip.v_2.OptionsFactory.createOptions(OptionsFactory.java:87)
        at org.jvnet.mjiip.v_2.OptionsFactory.createOptions(OptionsFactory.java:18)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:462)
        at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:311)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:567)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlAccessType
        at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3138)
        at java.base/java.lang.Class.getConstructor0(Class.java:3343)
        at java.base/java.lang.Class.getConstructor(Class.java:2152)
        at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:661)
        at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:658)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
        at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:669)
        ... 34 more
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlAccessType
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        ... 42 more

最佳答案

您可能没有使用 JAVA 8。请在项目属性中定义 Java 8,然后尝试再次构建它。如果您使用的是 Java9 或更高版本,因为它们放弃了类路径的使用,您需要添加 --add-modules java.xml.bind 作为 JVM 参数,以便连接 mdule

关于java - 无法获取公共(public)无参数构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59645714/

相关文章:

java - 如何让tomcat使用扩展名为.jar的文件夹作为jar文件?

java - Maven 故障安全插件失败并显示 "Unable to locate surefire-booter"

java - 有没有办法通过在 Jackson 中包含数组来确定抽象对象的目标类型?

java - 在单个 web.xml 中添加多个 servlet

android - 如何在图形设计器中预览 TabWidget 的内容

git - Maven 发布/Github OAuth token /Jenkins : could not read Username for 'https://github.com' : No such device or address

java - mvn generated-sources 失败,为什么 xml beans 不在类路径上?

Java - 返回整数数组的问题

java - 显示彩票中奖者

c++ - 不能使用 OpenCV 命名空间