Java WSDL-URL的Maven过滤
我正在尝试使用资源过滤为wsdl生成SOAP地址。但不知何故,它不起作用。我将插件和资源元素编写为:Java WSDL-URL的Maven过滤,java,maven,maven-resources-plugin,Java,Maven,Maven Resources Plugin,我正在尝试使用资源过滤为wsdl生成SOAP地址。但不知何故,它不起作用。我将插件和资源元素编写为: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <inherited>false</inherited> <executi
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<id>process-urls</id>
<phase>clean</phase>
<goals>
<goal>resources</goal>
</goals>
<inherited>false</inherited>
<configuration>
<delimiters>
<delimiter>${*}</delimiter>
</delimiters>
<filters>
<filter>src/main/resources/PO/WSDLFiles/ProcessOrder.wsdl</filter>
<filter>src/main/resources/DAC/WSDLFiles/InternalRequest.wsdl</filter>
</filters>
<overwrite>true</overwrite>
</configuration>
</execution>
</executions>
</plugin>
<resources>
<resource>
<directory>src/main/resources/</directory>
<includes>
<include>**/*</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
当我运行我的pom文件时,它也有一个CXF插件来生成类,我看到JAVA对象中的URL是通过以下方式生成的:
${protocol}://${fullhostname}:${port}/PO/services/ProcessOrderSoapHttpPort
它只是按原样拾取字符串,没有应用任何值。你能告诉我我做错了什么吗?我猜WSDL属性中的“”是导致问题的原因,但我可能错了。我假设Maven Resources插件按预期工作。如果使用调试模式
mvn clean install-X
,您将发现一些其他信息,如:
[DEBUG] file ProcessOrder.wsdl has a filtered file extension
[DEBUG] filtering /work/source/stackoverflow/wsdl-filtering/src/main/resources/PO/WSDLFiles/ProcessOrder.wsdl to /work/source/stackoverflow/wsdl-filtering/target/classes/PO/WSDLFiles/ProcessOrder.wsdl
[DEBUG] no use filter components
如果未指定
,则默认输出文件夹将为${project.build.outputDirectory}
(目标/类)
在这种情况下,只需在CXF插件中指定wsdl文件位置:
org.apache.cxf
cxf-codegen插件
${cxf.version}
生成源
生成源
${project.build.directory}/generated sources/cxf
${project.build.outputDirectory}/PO/WSDLFiles/ProcessOrder.wsdl
wsdl2java
不要使用同一目录,因为您将丢失原始文件的内容。结果将是一个空的wsdl文件
此外,我建议修复资源插件配置。您可以使用
来定义包含键值对的属性文件。使用
和
来代替您在构建部分中所做的操作。您运行哪一个maven目标?我通常运行清洁安装
或清洁部署
,所以您建议完全删除资源插件?只需依赖构建部分下的资源/过滤器标签。。。。我说得对吗?
[DEBUG] file ProcessOrder.wsdl has a filtered file extension
[DEBUG] filtering /work/source/stackoverflow/wsdl-filtering/src/main/resources/PO/WSDLFiles/ProcessOrder.wsdl to /work/source/stackoverflow/wsdl-filtering/target/classes/PO/WSDLFiles/ProcessOrder.wsdl
[DEBUG] no use filter components