我正在使用maven-jaxws-plugin从我的wsdl模式生成java类。它不会在生成的类中生成@XmlElementWrapper注释。从this帖子中我了解到我需要使用jaxb-xew-plugin,但无法让它与maven-jaxws-plugin一起工作。任何帮助都将不胜感激。下面是我尝试过的配置
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<xjcArgs>
<xjcArg>-no-header</xjcArg>
<xjcArg>-Xxew</xjcArg>
<xjcArg>-Xxew:instantiate lazy</xjcArg>
<xjcArg>-Xxew:delete</xjcArg>
</xjcArgs>
<extension>true</extension>
<wsdlDirectory>${basedir}/src/main/resources</wsdlDirectory>
<wsdlFiles>
<wsdlFile>attribute-service.wsdl</wsdlFile>
</wsdlFiles>
<sourceDestDir>${project.build.directory}/generated</sourceDestDir>
<verbose>true</verbose>
<keep>true</keep>
<plugins>
<plugin>
<groupId>com.github.jaxb-xew-plugin</groupId>
<artifactId>jaxb-xew-plugin</artifactId>
<version>1.0</version>
</plugin>
</plugins>
</configuration>
</execution>
</executions>
</plugin>如果它只能与maven-jaxb2-plugin集成,你能帮我把我的webservice安装好吗?本质上,我如何指定wsdl以及如何生成服务类?(使用@WebService注释)
谢谢,
巴吉亚
发布于 2014-01-14 22:35:09
虽然这篇文章在我写这篇文章的时候已经10个月了,但我还是回复它,以防有人需要它。
借助jaxws-maven-plugin和jaxb-xew-plugin,您可以为列表/数组对象生成@XmlElementWrapper批注
假设您的wsdl具有如下模式:
<xs:element name="books" minOccurs="0" >
<xs:complexType>
<xs:sequence>
<xs:element name="book" type="Book" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>它将java生成为:
@XmlElementWrapper(name = "books")
@XmlElement(name = "book")
protected List<Book> books;下面是构建/插件
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<configuration>
<wsdlDirectory>${project.basedir}/src/main/webapp/WEB-INF/wsdl/</wsdlDirectory>
<xjcArgs>
<xjcArg>-no-header</xjcArg>
<xjcArg>-Xxew</xjcArg>
<xjcArg>-Xxew:instantiate lazy</xjcArg>
<xjcArg>-Xxew:delete</xjcArg>
</xjcArgs>
</configuration>
<executions>
<execution>
<id>wsdl_import</id>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.github.jaxb-xew-plugin</groupId>
<artifactId>jaxb-xew-plugin</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2.4-1</version>
</dependency>
</dependencies>
</plugin> 发布于 2014-05-15 19:08:21
sample page of the jaxb xew plugin上提供了jaxws maven插件的配置示例。jaxws-maven-plugin 2.3.1-b03与jaxb-xew-plugin 1.2一起工作得很好。
https://stackoverflow.com/questions/15246950
复制相似问题