使用this maven plugin ,我能够生成我的类并在另一个模式中重用它们;这真的很棒!
现在我发现自己的模式需要两个情节(从模式生成的两个不同的包)。我只是尝试在 XJC 中添加另一个参数,但没有成功。
然后我更改了两个参数的顺序,错误针对的是另一个架构。然后我就明白这两集都不错,但可能不是做事的方式。
这是我的一些 pom:
<execution>
<id>business</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
..
<extension>true</extension>
<args>
<arg>-b</arg>
<arg>${project.basedir}/target/episodes/x.episode</arg>
<arg>${project.basedir}/target/episodes/y.episode</arg>
<arg>${project.basedir}/target/episodes/z.episode</arg>
</args>
..
</configuration>
</execution>
这是我得到的:
org.xml.sax.SAXParseException;系统ID:文件:/****.episode;行号:2;列数:65; s4s-elt-schema-ns:命名空间元素“绑定(bind)”必须来自“http://ww.w3.org/2001.XMLSchema” '。
据我了解(在交换他们的调用后),这三个模式/情节都很好,但我不能同时使用它们。有办法做到吗?
这里是新手,非常感谢任何帮助:)。
最佳答案
我之前在另一个项目中已经这样做过。我认为您使用了错误的语法:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>jaxb-Generic-XSD</id>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<enableIntrospection>false</enableIntrospection>
<schemaFiles>Generic.xsd</schemaFiles>
<schemaDirectory>${jaxb.schema.folder}</schemaDirectory>
<packageName>you.package.name.here</packageName>
<outputDirectory>${jaxb.output.folder}</outputDirectory>
<extension>true</extension>
<arguments>-b ${core.episode.file} -b ${containers.episode.file}</arguments>
</configuration>
</execution>
</executions>
</plugin>
注意:<arguments>-b ${core.episode.file} -b ${containers.episode.file}</arguments>
线。
我认为您使用的是相同的 Maven 插件,但如果不是,请记下插件版本 groupId、artifactId,然后使用它。
关于java - JAXB Maven 使用多个情节生成类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32140648/