我正在使用 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>
Run Code Online (Sandbox Code Playgroud)
该插件配置应与此处找到的配置相对应。当我运行构建时,从第一个架构生成的源文件也被放入第二个包中。谁能向我解释为什么会这样?这是一个错误还是我错过了什么?
非常感谢您的任何意见!
编辑:
我也尝试了 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> …Run Code Online (Sandbox Code Playgroud)