Maven JAXB2 XJC插件:未涵盖M2E插件执行 [英] Maven JAXB2 XJC plugin: M2E plugin execution not covered

查看:156
本文介绍了Maven JAXB2 XJC插件:未涵盖M2E插件执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jaxb2 xjc 插件从 XSD 生成java文件。因此,我曾经按如下方式配置我的pom.xml:

I am using using the jaxb2 xjc plugin for generating java files from a XSD. Therefore I used to configure my pom.xml as follows:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>1.3</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <packageName>com.mypackage.model</packageName>
                <schemaDirectory>${basedir}/src/main/resources/XSD</schemaDirectory>
            </configuration>
        </plugin>
        <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <configuration>
               <source>1.6</source>
               <target>1.6</target>
           </configuration>
       </plugin>
    </plugins>
</build>

我将开发环境改为Eclipse Indigo,这不再适用。错误说:生命周期配置未涵盖插件执行。我知道我必须以不同的方式定义我的插件的执行,以便它在我的新环境中工作。

I changed my developing environment to Eclipse Indigo and this does not work any more. The error says: "Plugin execution not covered by lifecycle configuration". I understand I have to define the execution of my plugin differently so that it works in my new environment.

我按照本页上的说明未涵盖M2E插件执行但是在执行 generate-sources 阶段时不会生成源文件。

I followed the instructions on this page M2E plugin execution not covered but the source files are not generated when executing the generate-sources phase.

任何人都可以显示我如何精确地重构我的pom以便正确生成我的文件?

Could anybody show me how to exactly refactor my pom so that my files are properly generated?

感谢您的帮助!

推荐答案

事实证明我 最终找到了答案! Eclipse与Maven的集成已经知道许多Maven插件的兼容性问题。

It turns out that I did eventually find an answer! Eclipse's integration with Maven has known compatibility issues with numerous Maven plugins.

当您可以从Eclipse外部的命令行成功运行Maven构建时,但Eclipse在POM中显示执行未覆盖错误,请尝试添加此插件:

When you can successfully run a Maven build from the command-line outside of Eclipse, yet but Eclipse shows "execution not covered" errors in your POM, then try adding this plugin:

<build>
    ...
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.codehaus.mojo</groupId>
                                    <artifactId>jaxb2-maven-plugin</artifactId>
                                    <versionRange>[1.3,)</versionRange>
                                    <goals>
                                        <goal>xjc</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute />
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

如上面的评论所示,这个插件在Eclipse之外没有做任何事情。它只是告诉Eclipse何时执行JAXB插件,因为Eclipse不够智能,无法自行解决。

As indicated in the above comment, this plugin doesn't do anything outside of Eclipse. It simply tells Eclipse when to execute the JAXB plugin, since Eclipse isn't smart enough to figure that out on its own.

我在另一个StackOverflow问题,并将其采用到jaxb2-maven-plugin插件,而不是另一个问题中的插件。

I found this snippet on another StackOverflow question, and adopted it to the "jaxb2-maven-plugin" plugin rather than the plugin at issue in the the other question.

这篇关于Maven JAXB2 XJC插件:未涵盖M2E插件执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆