【问题标题】:Mojo schemagen maven plugin wrongly generates classMojo schemagen maven 插件错误地生成类
【发布时间】:2013-05-16 09:42:51
【问题描述】:

大家早上好, 我正在尝试在我的应用程序中使用 mojo jaxb2 maven 插件,但是只要正确创建了架构,它就会在同一个文件夹中生成整个类(作为 .class)。 我会说由于某种原因,maven/compiler 在 /schemas/ 文件夹中创建了输出类。 关键是我只想输出将在其他项目中使用的 *.xsd 文件。 这是我的 pom 的摘录:

<plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <id>schemagen</id>
                        <goals>
                            <goal>schemagen</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>com/delagelanden/rijee6/domain/*.java</include>
                            </includes>
                            <outputDirectory>${project.build.directory}/schemas</outputDirectory>
                             <verbose>true</verbose>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

【问题讨论】:

    标签: maven plugins pom.xml jaxb2 schemagen


    【解决方案1】:

    有人在这里提出了同样的问题 [1],这似乎是一个悬而未决的问题。

    我找到的解决方案是使用 maven-resources-plugin [2] 中的“复制资源”目标,仅包括 .xsd 文件。

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>1.5</version>
                <executions>
                    <execution>
                        <id>schemagen</id>
                        <goals>
                            <goal>schemagen</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <includes>
                        <include>**/*.java</include>
                    </includes>
                    <outputDirectory>${project.build.directory}/generated-resources/schemas</outputDirectory>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}/META-INF/schema</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.build.directory}/generated-resources/schemas</directory>
                                    <includes>
                                        <include>**/*.xsd</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    

    [1]http://mojo.10943.n7.nabble.com/Maven-Jaxb2-plugin-schemagen-generating-classes-td40005.html [2]http://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-10
      • 1970-01-01
      • 1970-01-01
      • 2013-09-30
      • 1970-01-01
      • 2019-12-07
      • 1970-01-01
      • 2015-07-14
      相关资源
      最近更新 更多