我有这个Maven"任务"使用JAXB从XSD文件生成Java类.
<!-- XML to Java classes -->
<plugin>
<groupId>com.sun.tools.xjc.maven2</groupId>
<artifactId>maven-jaxb-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generatePackage>nl.compay.service</generatePackage>
<schemaDirectory>src/main/webapp/compay</schemaDirectory>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
对于XSD类型"User",它会生成一个名为"User"(duh)的类.但是,我还有一个名为"User"的JPA实体类(虽然在不同的包中).我可以更改上面的XML配置,让JAXB为生成的类添加"XML"之类的前缀吗?
我正在使用ant wsimport从wsdls生成客户端存根.另外,我想生成实现的客户端类Serializable.我想serialVersionUID为每个班级生成一个不同的.我尝试使用下面显示的绑定文件.但它serialVersionUID为所有类生成相同.有什么方法可以把我自己serialVersionUID的每个班级都给自己?
<wsimport xendorsed="true" binding="binding.xml" debug="true" keep="true"
verbose="false" sourcedestdir="${generated}" wsdl="${src}${wsdl.file}"
wsdlLocation="${wsdl.file}">
</wsimport>
Run Code Online (Sandbox Code Playgroud)
绑定配置
<bindings xmlns="http://java.sun.com/xml/ns/jaxb" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<globalBindings>
<serializable uid="1" />
</globalBindings>
</bindings>
Run Code Online (Sandbox Code Playgroud) 拥有JAXB-RI和CXF.WSDL优先.我想要一个生成的类来实现Serializable.我现在有以下绑定xml,它可以工作(SEI类名称被更改)
<jaxws:bindings xmlns:xsd="http://www.w3.org/2001/XMLSchema" ...>
<bindings node="wsdl:definitions/wsdl:portType[@name='Foo']">
<!-- change the generated SEI class -->
<class name="IFooService" />
</bindings>
</jaxws:bindings>
Run Code Online (Sandbox Code Playgroud)
不,在这种情况下,我应该添加的位置和内容.我试过了:
<xsd:annotation>
<xsd:appinfo>
<jaxb:globalBindings>
<xjc:serializable uid="12343" />
</jaxb:globalBindings>
</xsd:appinfo>
</xsd:annotation>
Run Code Online (Sandbox Code Playgroud)
和
<jxb:globalBindings>
<jxb:serializable/>
</jxb:globalBindings>
Run Code Online (Sandbox Code Playgroud)
<bindings>标记内部和外部- 要么Serializable未添加,要么根本不生成类(没有任何错误).
另见此主题
那么,究竟如何做到这一点
我正在使用Maven插件jvnet
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
Run Code Online (Sandbox Code Playgroud)
从xsd生成jaxb类。
我希望所有jaxb类都必须实现可序列化的接口。请让我知道该怎么做。
如何强制CXF序列化所有自动生成的客户端类?运行客户端生成器时需要传递的任何参数?