maven-jaxb2-plugin报告前缀已绑定,仅在Eclipse中

时间:2019-06-17 16:07:02

标签: java eclipse maven jaxb

我正在尝试调试基于Maven的Spring Boot项目。它进行SOAP调用,并使用org.jvnet.jaxb2.maven2组中的maven-jaxb2-plugin工件从WSDL文件生成Java类。

当我从mvn命令行构建此项目时,它会正常构建。

但是,当我将其加载到Eclipse(2019-03)中时,在“问题”视图中看到这样的错误:

org.apache.maven.plugin.PluginExecutionException: Execution addrole of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.3:generate failed: Prefix '' is already bound to ''
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:148)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.lambda$7(MavenImpl.java:1342)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1341)
    at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52)
    at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:173)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:116)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:106)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:87)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:201)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:833)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:220)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:263)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:316)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:319)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:371)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:392)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:154)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:244)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.lang.IllegalArgumentException: Prefix '' is already bound to ''
    at com.sun.xml.txw2.StartTag.addNamespaceDecl(StartTag.java:191)
    at com.sun.xml.txw2.ContainerElement._namespace(ContainerElement.java:333)
    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 com.sun.xml.txw2.ContainerElement.invoke(ContainerElement.java:134)
    at com.sun.proxy.$Proxy60._namespace(Unknown Source)
    at com.sun.tools.xjc.addon.episode.PluginImpl.run(PluginImpl.java:174)
    at com.sun.tools.xjc.model.Model.generateCode(Model.java:292)
    at org.jvnet.mjiip.v_2_2.XJC22Mojo.generateCode(XJC22Mojo.java:66)
    at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:41)
    at org.jvnet.mjiip.v_2_2.XJC22Mojo.doExecute(XJC22Mojo.java:28)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.doExecute(RawXJC2Mojo.java:473)
    at org.jvnet.jaxb2.maven2.RawXJC2Mojo.execute(RawXJC2Mojo.java:316)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
    ... 30 more

插件在pom中的引用如下:

    <plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.13.3</version>
    <executions>
        <execution>
            <id>suggestHandle</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <schemaDirectory>${project.basedir}/src/main/resources/schemas/mpssoap</schemaDirectory>
                <schemaIncludes>
                    <include>*.wsdl</include>
                </schemaIncludes>
                <clearOutputDir>false</clearOutputDir>
            </configuration>
        </execution>

之后是十二个左右的执行元素,指向src / main / resources的不同子目录。

我已经安装了“用于jaxb的m2e连接器”插件,但这似乎没有任何区别。

这里还有什么问题吗?

我正在使用Eclipse 2019-03和maven-jaxb2-plugin工件的v0.13.3。

1 个答案:

答案 0 :(得分:2)

您能对照在命令行中使用的版本检查Eclipse使用的JDK版本吗? 使用Zulu 11和jaxb2时,我也遇到类似的问题。 由于这可能与https://github.com/eclipse-ee4j/jaxb-ri/issues/1220有关,请尝试使您符合Eclipse JDK的要求,以匹配您在控制台中使用的版本。

编辑:从Maven 3.6.0升级到3.6.3可以解决我的问题,希望对您来说也是如此。