如何让JAXB2发出CamelCase绑定? [英] How can I get JAXB2 to emit CamelCase bindings?
问题描述
我正在使用jaxws-maven-plugin的 wsimport 目标。开箱即用,这将从XML模式生成可怕的类和方法;例如,来自名为MY_OBJECT的XML元素的名为MYOBJECT的类。
I'm generating Java classes from a WSDL using the jaxws-maven-plugin's wsimport goal. Out of the box, this generates hideous classes and methods from the XML schema; e.g., a class called MYOBJECT from an XML element named MY_OBJECT.
我发现我可以使用外部文件自定义我的JAXB2绑定;这对于少量的类和方法是可以接受的,但是在这种情况下手动命名所有内容的开销是不可取的。
I've found that I can customize my JAXB2 bindings with an external file; this would be acceptable for a small number of classes and methods, but the overhead of manually naming everything in this case is undesirable.
一些搜索揭示了对 XJC CamelCase始终插件,但这似乎没有维护,大多数链接是404s。我不想放弃,我确实找到了 camelcase-always Maven工件似乎提供了这项功能,但我不知道如何配置它以便jaxws-maven-plugin使用它。
Some searching uncovers references to an XJC CamelCase Always plugin, but this appears to be unmaintained and most links are 404s. Not willing to give up, I did find a camelcase-always Maven artifact which appears to provide this functionality, but I'm not sure how to configure this so that jaxws-maven-plugin uses it.
怎么能我没有手动指定CamelCase绑定吗?
How can I get CamelCase bindings without specifying them all manually?
推荐答案
我没有找到如何用<$ c执行此操作的示例$ c> jaxws-maven-plugin ,但我确实找到了使用 maven-jaxb2-plugin
的例子。
I didn't find examples of how to do this with jaxws-maven-plugin
, but I did find examples using the maven-jaxb2-plugin
.
首先,您需要在POM中添加一个存储库:
First, you need a repository added to your POM:
<repository>
<id>releases</id>
<name>Releases</name>
<url>https://oss.sonatype.org/content/repositories/releases</url>
</repository>
注意插件声明和参数添加到 maven-jaxb2-plugin
执行。
Note the plugin declaration and arguments added to the maven-jaxb2-plugin
execution.
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<id>jaxb-generate</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generatePackage>YOUR.PACKAGE.HERE</generatePackage>
<args>
<arg>-camelcase-always</arg>
</args>
<bindingDirectory>src/main/binding</bindingDirectory>
<schemas>
<schema>
<url>http://YOUR.WSDL.HERE</url>
</schema>
</schemas>
<extension>true</extension>
<plugins>
<plugin>
<groupId>org.andromda.thirdparty.jaxb2_commons</groupId>
<artifactId>camelcase-always</artifactId>
<version>1.0</version>
</plugin>
</plugins>
</configuration>
</plugin>
参见 docs 了解更多详情。
这篇关于如何让JAXB2发出CamelCase绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!