Maven Jaxb2 插件错误

Posted

技术标签:

【中文标题】Maven Jaxb2 插件错误【英文标题】:Maven Jaxb2 plugin errors 【发布时间】:2012-03-02 02:13:30 【问题描述】:

尝试使用 NetBeans 构建 mavenized 项目失败:

未能在项目 MyProject 上执行目标 org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.7.5:generate(默认):

目标 org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.7.5:generate failed 的执行默认:

执行 org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.7.5:generate:org/codehaus/plexus/util/DirectoryScanner 时缺少必需的类

realm =    plugin>org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.7.5

strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy

urls[0] = file:/C:/Users/user/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin/0.7.5/maven-jaxb2-plugin-0.7.5.jar

urls[1] = file:/C:/Users/user/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin-core/0.7.5/maven-jaxb2-plugin-core-0.7.5.jar

urls[2] = file:/C:/Users/user/.m2/repository/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar

urls[3] = file:/C:/Users/user/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar

urls[4] = file:/C:/Users/user/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar

urls[5] = file:/C:/Users/user/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar

urls[6] = file:/C:/Users/user/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar

urls[7] = file:/C:/Users/user/.m2/repository/org/jfrog/maven/annomojo/maven-plugin-anno/1.3.1/maven-plugin-anno-1.3.1.jar

urls[8] = file:/C:/Users/user/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb22-plugin/0.7.5/maven-jaxb22-plugin-0.7.5.jar

urls[9] = file:/C:/Users/user/.m2/repository/com/sun/xml/bind/jaxb-impl/2.2.2/jaxb-impl-2.2.2.jar

urls[10] = file:/C:/Users/user/.m2/repository/javax/xml/bind/jaxb-api/2.2.2/jaxb-api-2.2.2.jar

urls[11] = file:/C:/Users/user/.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar

urls[12] = file:/C:/Users/user/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar

urls[13] = file:/C:/Users/user/.m2/repository/com/sun/xml/bind/jaxb-xjc/2.2.2/jaxb-xjc-2.2.2.jar

Number of foreign imports: 1

import: Entry[import  from realm ClassRealm[maven.api, parent: null]]

我的 POM.xml 看起来像这样:

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.7.5</version>
    <executions>
        <execution>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>

    <configuration>
        <schemaDirectory>src/main</schemaDirectory>
        <schemaIncludes>
            <include>package/aFile.xsd</include>
        </schemaIncludes>
        <generateDirectory>src/generated</generateDirectory>
        <generatePackage>package.jaxb2</generatePackage>
        <readOnly>true</readOnly>
    </configuration>
</plugin>

DirectoryScanner 类是 plexus-utils 的一部分,我已将其列为依赖项并安装在我的本地存储库中。

编辑:显然,如果我添加 plexus-utils 作为 jaxb2 插件的 依赖项,一切正常。

【问题讨论】:

【参考方案1】:

请尝试 0.8.1 版本。以前的版本有this problem的问题,现在应该更正了。

【讨论】:

以上是关于Maven Jaxb2 插件错误的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 jaxb2-maven-plugin 2.x 从 WSDL 生成 Java 类?

在jaxb2-maven-plugin中为schemagen添加显式源目录

哪个是生成 Web 服务客户端的最佳 Maven 插件?

无法使用jaxb2-maven-plugin将WSDL解析为不同的包

JAXB 3.0(Jakarta EE 9)是不是有任何 maven 插件?

Maven 错误:插件的描述符包含错误的版本