在遇到http://java.net/jira/browse/JAXB-131之后,我们正在尝试采用其注释中提供的解决方案,即在xjc的命令行上提供-enableIntrospection。
然而,当我这样做的时候:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
<executions>
<execution>
<id>allservice</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<xjcArgs><xjcArg>-enableIntrospection</xjcArg></xjcArgs>
<extension>true</extension>
<wsdlDirectory>src/main/webapp/WEB-INF/wsdl</wsdlDirectory>
<bindingDirectory>src/main/resources/bindings</bindingDirectory>
<target>2.0</target>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.jws</groupId>
<artifactId>jsr181-api</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>maven构建失败,出现以下错误:
[DEBUG] The binding Directory is C:\Source\workspace\TheProject\src\main\resources\bindings
[DEBUG] jaxws:wsimport args: [-s, C:\Source\workspace\TheProject\target\jaxws\wsimport\java, -d, C:\Source\workspace\TheProject\target\classes, -target, 2.0, -extension, -Xnocompile, -B-enableIntrospection, -b, C:\Source\workspace\TheProject\src\main\resources\bindings\servicebindings.xml]
[INFO] jaxws:wsimport args: [-s, C:\Source\workspace\TheProject\target\jaxws\wsimport\java, -d, C:\Source\workspace\TheProject\target\classes, -target, 2.0, -extension, -Xnocompile, -B-enableIntrospection, -b, C:\Source\workspace\TheProject\src\main\resources\bindings\servicebindings.xml, C:\Source\workspace\TheProject\src\main\webapp\WEB-INF\wsdl\CaseService.wsdl]
no such JAXB option: -enableIntrospection如何将xjc的插件与jaxws-maven- -enableIntrospection一起使用?如果不能,那么有什么替代方法可以定制jaxws的代码生成,以便将Boolean属性的getter称为getFoo() (正确)而不是isFoo() (这违反了Java Beans规范)。
发布于 2011-02-04 02:01:43
jaxws-maven-plugin似乎使用了已安装的JDK中的xjc。在添加对-enableIntrospection的支持之前,最新的Oracle JDK仍然包含XJC的一个版本。
接下来,我研究了如何使用JAXB插件。It turns out指出,jaxws-maven-plugin没有提供简单的方法来附加到XJC的类路径中,这是加载JAXB-plugin所必需的。
出于政治原因,替换jaxws-maven-plugin是不可能的(类似于"jaxws是标准,只能使用标准库“)。
因此,我又开始编写一个maven插件,它可以在一代又一代地读取源代码。
content.replace("public Boolean is", "public Boolean get");并将源文件写回到磁盘。这也允许我注入equals()和hashCode()的定义,这些定义依赖于我正在使用的应用程序接口中的业务键的命名约定。
发布于 2013-11-08 22:34:18
将用于布尔值的getter添加到JAX-WS生成的工件中,而不是使用enableIntrospection选项和Java认可的覆盖机制。
只有JAX-WSRI2.1.13支持选项enableIntrospection。但是JavaSE6 1.6.0_65附带了JAVA-WS RI 2.1.6。解决这个问题的一种方法是使用Java认可的覆盖机制,将jaxws-api.jar和jaxb-api.jar复制到JRE/JDK认可的目录中。
另一种方法是不使用enableIntrospection选项,而是将Booleans的getter添加到JAX-WS生成的工件中。这些getter可以通过replacer maven插件添加。
添加get方法的Maven替换插件:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<basedir>${project.basedir}</basedir>
<includes>
<include>src/main/java/lu/etat/cie/rn/rpp/ws/**/*.java</include>
</includes>
<token>public Boolean is(.*)\(\)(\s*\{\s*.+\s*\})</token>
<value>public Boolean is$1\(\)$2
public Boolean get$1\(\)$2</value>
</configuration>
</plugin>替换:
public Boolean isProperty() {
return property;
}通过以下方式:
public Boolean isProperty() {
return property;
}
public Boolean getProperty() {
return property;
}发布于 2021-03-24 08:08:35
你可以试试
<enableIntrospection>true</enableIntrospection>在<configuration>中,我还可以找到:
<args>
<arg>-enableIntrospection</arg>
</args>在……里面
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>https://stackoverflow.com/questions/4586927
复制相似问题