我如何告诉Maven将XSD生成的Java源放在不同的包中?

问题描述 投票:1回答:1

我正在使用mojohaus jaxb2-maven-plugin从xsd模式文件中生成Java源。我的pom.xml看起来像这样:

...    
<plugin>

            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxb2-maven-plugin</artifactId>
            <version>2.5.0</version>
            <executions>
                <execution>
                    <id>xjc-1</id>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                    <configuration>
                        <packageName>my.first.package.types</packageName>
                        <sources>
                            <source>src/main/java/META-INF/wsdl/firstSchema.xsd</source>                                
                        </sources>                          
                    </configuration>
                </execution>
                <execution>
                    <id>xjc-2</id>
                    <goals>
                        <goal>xjc</goal>
                    </goals>
                    <configuration>
                        <packageName>my.second.package.types</packageName>
                        <sources>                                                       
                            <source>src/main/java/META-INF/wsdl/secondSchema.xsd</source>
                        </sources>
                        <clearOutputDir>false</clearOutputDir>              
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <outputDirectory>src/main/javagen</outputDirectory>
            </configuration>
        </plugin>

此插件配置应对应于here。当我运行构建时,从第一个架构生成的源文件被放入第二个包中。谁能向我解释为什么会这样?那是一个错误还是我错过了什么?非常感谢您的输入!

编辑:

我也尝试过maven-jaxb2-plugin。结果一样!因此,这似乎是一个普遍的问题。我的maven-jaxb2-plugin插件配置如下:

... <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <version>0.14.0</version> <executions> <execution> <id>first</id> <goals> <goal>generate</goal> </goals> <configuration> <schemaIncludes> <include>firstSchema.xsd</include> </schemaIncludes> <generatePackage>my.first.package.types</generatePackage> </configuration> </execution> <execution> <id>second</id> <goals> <goal>generate</goal> </goals> <configuration> <schemaIncludes> <include>secondSchema.xsd</include> </schemaIncludes> <generatePackage>my.second.package.types</generatePackage> </configuration> </execution> </executions> <configuration> <schemaDirectory>src/main/java/META-INF/wsdl</schemaDirectory> <generateDirectory>src/main/javagen</generateDirectory> </configuration> </plugin>

有人有什么想法吗?这开始让我有些烦恼...

我正在使用mojohaus jaxb2-maven-plugin从xsd模式文件中生成Java源。我的pom.xml看起来像这样:...

org.codehaus.mojo

java maven xjc maven-jaxb2-plugin jaxb2-maven-plugin
1个回答
0
投票
我有同样的问题。请帮助回答这个问题!
© www.soinside.com 2019 - 2024. All rights reserved.