Good Morning everyone, I'm trying to use the mojo jaxb2 maven plugin in my application, however whenever the schema gets created properly, in the same folder it generates the whole classes (as a .class). I would say that for some reason the maven/compiler is creating the output classes in the /schemas/ folder. The point is that I would like to output just the *.xsd files that will be used in other projects. here is an excerpt from my 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>

没有正确的解决方案

其他提示

Someone asked the same question here [1] and this seems to be an open issue.

The solution I found was to use the 'copy-resources' goal from maven-resources-plugin [2] including only the .xsd files.

        <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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top