apache cxf-codegen-plugin wsdl2java 忽略 WSDL 选项
apache cxf-codegen-plugin wsdl2java ignore WSDL options
我需要从两个 wsdl 文件生成 java 代码。下面的 pom.xml 适合我。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.luvva</groupId>
<artifactId>cxf-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<cxf.sourceRoot>${project.build.directory}/generated-sources/annotations</cxf.sourceRoot>
<cxf.version>3.4.2</cxf.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<configuration>
<wsdlRoot>${project.basedir}/src/main/resources/wsdl</wsdlRoot>
<includes>
<include>*.wsdl</include>
</includes>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
问题是这些 wsdl 文件声明了一些具有相同名称和命名空间的元素。因此,其中一个在代码生成期间会覆盖另一个。我尝试了以下 pom.xml,但所有配置都被忽略了。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.luvva</groupId>
<artifactId>cxf-test-2</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<cxf.version>3.4.2</cxf.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/annotations</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/vw_proposals.wsdl</wsdl>
<extraargs>
<extraarg>-P</extraarg>
<extraarg>http://www.vwfsbr.com.br/servicebus=br.com.vwfsbr.proposals</extraarg>
</extraargs>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/vw_tables.wsdl</wsdl>
<extraargs>
<extraarg>-P</extraarg>
<extraarg>http://www.vwfsbr.com.br/servicebus=br.com.vwfsbr.tables</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
如何让插件正常工作?我还尝试了 -autoNameResolution 和 packageNames。没有任何效果,好像配置被忽略了。
wsdl 文件可用 here and here。 (使用下面的命令下载它们)。
curl [link] >> [fileName]
直接执行插件时,忽略配置。
当插件 运行 在 maven 生成源代码阶段时,配置没有被忽略并且工作正常。
我需要从两个 wsdl 文件生成 java 代码。下面的 pom.xml 适合我。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.luvva</groupId>
<artifactId>cxf-test</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<cxf.sourceRoot>${project.build.directory}/generated-sources/annotations</cxf.sourceRoot>
<cxf.version>3.4.2</cxf.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<configuration>
<wsdlRoot>${project.basedir}/src/main/resources/wsdl</wsdlRoot>
<includes>
<include>*.wsdl</include>
</includes>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
问题是这些 wsdl 文件声明了一些具有相同名称和命名空间的元素。因此,其中一个在代码生成期间会覆盖另一个。我尝试了以下 pom.xml,但所有配置都被忽略了。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.luvva</groupId>
<artifactId>cxf-test-2</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<cxf.version>3.4.2</cxf.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/annotations</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/vw_proposals.wsdl</wsdl>
<extraargs>
<extraarg>-P</extraarg>
<extraarg>http://www.vwfsbr.com.br/servicebus=br.com.vwfsbr.proposals</extraarg>
</extraargs>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/vw_tables.wsdl</wsdl>
<extraargs>
<extraarg>-P</extraarg>
<extraarg>http://www.vwfsbr.com.br/servicebus=br.com.vwfsbr.tables</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
如何让插件正常工作?我还尝试了 -autoNameResolution 和 packageNames。没有任何效果,好像配置被忽略了。
wsdl 文件可用 here and here。 (使用下面的命令下载它们)。
curl [link] >> [fileName]
直接执行插件时,忽略配置。 当插件 运行 在 maven 生成源代码阶段时,配置没有被忽略并且工作正常。