jaxb2-maven-plugin是一个m2e连接器

时间:2017-10-10 09:48:56

标签: eclipse maven m2eclipse m2e jaxb2-maven-plugin

在从repo清理结账/克隆之后,我在执行jaxb2-maven-plugin xjc目标时在eclipse中收到此错误。 在“更新Maven配置”之后,代码仍未生成。 在我的neon3 eclipse(4.6.3)中,我安装了m2e插件(1.7.1)和“m2e connector for jaxb2”(4.0.0)

null (org.codehaus.mojo:jaxb2-maven-plugin:2.2:xjc:xjc-evu:generate-sources)

org.apache.maven.plugin.MojoExecutionException
    at org.codehaus.mojo.jaxb2.javageneration.AbstractJavaGeneratorMojo.performExecution(AbstractJavaGeneratorMojo.java:482)
    at org.codehaus.mojo.jaxb2.AbstractJaxbMojo.execute(AbstractJaxbMojo.java:257)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
    at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1360)
    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:172)
    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:115)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    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:105)
    at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
    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:86)
    at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:301)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:304)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:360)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:383)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.NullPointerException
    at org.codehaus.mojo.jaxb2.shared.environment.ToolExecutionEnvironment.restore(ToolExecutionEnvironment.java:182)
    at org.codehaus.mojo.jaxb2.javageneration.AbstractJavaGeneratorMojo.performExecution(AbstractJavaGeneratorMojo.java:427)
    ... 33 more

在同一个pom.xml中,它在lifecycle-mapping下标记为

<action>
    <execute>
        <runOnIncremental>false</runOnIncremental>
        <runOnConfiguration>true</runOnConfiguration>
    </execute>
</action>

Here表示bitstrings连接器应该支持jaxb2-maven-plugin,并且在this comment from the Author我可以看到自版本1.0.3.201107311209以来有支持。然而,在作者主页上说明了

  

插件:org.codehaus.mojo:jaxb2-maven-plugin主页:

     

http://mojo.codehaus.org/jaxb2-maven-plugin

     

(注意:jaxb2-maven-plugin版本1.5 +不需要)

我应该使用哪个m2e连接器或pom.xml配置使jaxb2-maven-plugin在eclipse中工作(意思是,它会在更新配置的generate-sources阶段产生影响并将生成的文件夹添加到classpath中)?< / p>

2 个答案:

答案 0 :(得分:0)

我的解决方法:在清理结帐后,手动运行Maven generate-sources阶段,并配置build-helper插件,将jaxb文件夹作为resources文件夹添加到eclipse项目中(为此你需要当然是build-helper-maven-plugi n)的m2e连接器

答案 1 :(得分:0)

mvn clean install为我工作。