错误Listener在将maven-jaxb-plugin与eclipse和m2e一起使用时丢失

2022-09-02 11:41:33

我已经为插件设置了一个项目”。它的工作原理,但我不喜欢Eclipse编辑器中显示的“pom.xml”错误消息。该消息指出:org.jvnet.jaxb2.maven2:maven-jaxb2-plugin"

Execution default of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate failed: A required class was missing while executing org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate: com/sun/xml/bind/api/ErrorListener

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>de.gombers.lernen.jaxb</groupId>
    <artifactId>PlayWithJAXB</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9.1</version>
                <configuration>
                    <show>private</show>
                    <nohelp>true</nohelp>
                </configuration>
            </plugin>


            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.13.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <extension>true</extension>
                    <useDependenciesAsEpisodes>true</useDependenciesAsEpisodes>
                    <outputDirectory>target/generated-sources/jaxb</outputDirectory>
                    <packageName>de.gombers.lernen.jaxb.generated</packageName>
                    <schemaDirectory>src/main/resources</schemaDirectory>
                    <schemaFiles>Employee.xsd</schemaFiles>
                </configuration>
            </plugin>

        </plugins>


    </build>

    <dependencies>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>

        <!-- JAXB -->
        <dependency>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb2-plugin-core</artifactId>
            <version>0.13.1</version>
        </dependency>
        <dependency>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <artifactId>maven-jaxb22-plugin</artifactId>
            <version>0.13.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-project</artifactId>
            <version>2.0.9</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-annotations</artifactId>
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-settings</artifactId>
            <version>2.0.9</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-container-default</artifactId>
            <version>1.0-alpha-9-stable-1</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.2.7</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.7</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.2.7</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-jxc</artifactId>
            <version>2.2.7</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-xjc</artifactId>
            <version>2.2.7</version>
        </dependency>


        <!-- HELPERS -->
        <dependency>
            <groupId>de.gombers</groupId>
            <artifactId>BasicTools</artifactId>
            <version>1.0.0</version>
        </dependency>

        <!-- LOGGING -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.13</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.2</version>
        </dependency>

        <!-- JUNIT -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.8.4</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>

        <!-- JSON converter -->
        <dependency>
            <artifactId>jackson-core</artifactId>
            <groupId>com.fasterxml.jackson.core</groupId>
            <version>2.3.3</version>
        </dependency>
        <dependency>
            <artifactId>jackson-annotations</artifactId>
            <groupId>com.fasterxml.jackson.core</groupId>
            <version>2.3.3</version>
        </dependency>
        <dependency>
            <artifactId>jackson-databind</artifactId>
            <groupId>com.fasterxml.jackson.core</groupId>
            <version>2.3.3</version>
        </dependency>

    </dependencies>
</project>

我的 “” 命令没有声明任何错误,并且声明的 ErrorListener 与工件 “” 一起提供。如前所述,当运行项目以生成源代码时,它工作正常。有没有人运行这个插件,可以分享他的pom.xml?mvn validatecom.sun.xml.bind:jaxb-core


答案 1

将插件更新到版本 0.13.3 可解决此问题。


答案 2

我通过从 Eclipse 首选项(Java >已安装的 JREs)中删除任何 JRE 并仅将选定的 JDK 保留在那里来解决此问题。即使未选择 JRE,它们仍会导致问题,必须将其删除。我能够将 JRE 留在我的系统上。这篇文章很有帮助: http://diggingthroughcode.blogspot.ca/2016/05/trouble-with-maven-jaxb2-plugin-and.html

[更新]另一位同事刚刚遇到了这个问题,对他来说,关键因素似乎是使用哪个Java来运行Eclipse。它不会使用JAVA_HOME配置的内容,而是第一个可用的Java运行时。他从他的系统中删除了所有jres,只留下了一个jdk,这解决了这个问题。我相信关键因素是日食是用jre还是jdk运行。当我解决了这个问题时,我确实从我的系统中删除了一个jre,这可能是eclipse一直在使用的。由于这个jre丢失了,它切换到了jdk,即使我有其他jre可用。如果您不想从系统中删除 jres,可以指定应使用哪种 java 运行时 eclipse(如何使用不同的 java 版本运行 eclipse?)。如果没有指定任何内容,eclipse 将确定要使用的 java 运行时(找出运行 JVM Eclipse 的是什么)。


推荐