使用this maven plugin,我能够生成我的类并在另一个模式中重用它们;这太棒了!
现在我发现自己的模式需要两集(从模式生成两个不同的包)。我只是试图在XJC中添加另一个arg,但它没有用。
然后我改变了两个args的顺序,错误的目标是另一个模式。然后我才知道这两集都很好,但它可能不是做事的方式。
这是我的一些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; systemId:file:/ ****。episode; lineNumber:2; columnNumber:65; s4s-elt-schema-ns:名称空间元素'bindings'必须来自'http://ww.w3.org/2001.XMLSchema'。
根据我的理解(交换他们的电话后),三个模式/剧集很好,但我不能同时使用它们。有办法吗?
新手在这里,任何帮助非常感谢:)。
答案 0 :(得分:1)
我之前在另一个项目上做过这个。我认为你使用了错误的语法:
<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,然后使用它。
答案 1 :(得分:1)
此处maven-jaxb2-plugin的作者。
为什么使用args
,为什么不在配置中添加剧集?
<episodes>
<episode>
<groupId>com.acme.foo</groupId>
<artifactId>package1</artifactId>
<!-- Version is not required if the artifact is
configured as dependency -->
</episode>
<episode>
<groupId>com.acme.foo</groupId>
<artifactId>package2</artifactId>
<!-- Version is not required if the artifact is
configured as dependency -->
</episode>
</episodes>
剧集的整个想法是你可以指向JAR(包含剧集文件),XJC将找出并使用所包含剧集中的绑定。将arg
与-b
一起使用并不是它的意图。 :)
关于您所看到的错误,我猜您配置arg
的方式会让XJC认为您的第二集和更多集实际上是模式。我会尝试放置中间-b
参数或配置您在一个arg
中引用的所有剧集。
但我仍然认为这不是使用剧集的正确方法。将您的剧集编译为单独的JAR /单独的Maven模块,将它们用作依赖项,并将它们配置为episodes
或只打开useDependenciesAsEpisodes
选项。