将属性中的 WSDL URL 添加到 pom

Add WSDL URL from properties into pom

不确定这个问题是否已经得到解答,但我已经在 google 和 Whosebug 中查找了一段时间,但没有找到满足我需要的内容。

我有一个 pom.xml 文件,我在其中定义了一个 属性(这是一个 WSDL URL):

<properties>
    <service.wsdl.url>https://myservice.com/testservice.asmx?wsdl</service.wsdl.url>
</properties>

然后我使用 wsimport 为 Web 服务组件生成定义了一个插件:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <id>myservice</id>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <wsdlUrls>
                            <wsdlUrl>${service.wsdl.url}</wsdlUrl>
                        </wsdlUrls>
                        <packageName>com.myservice.generated</packageName>
                        <sourceDestDir>src/main/java</sourceDestDir>
                        <args>
                            <arg>-B-XautoNameResolution</arg>
                        </args>
                    </configuration>
                </execution>
            </executions>
        </plugin>

我的问题是如何从属性文件中获取 URL。我的 src/main/resources 文件夹中有一个名为 "application.properties" 的属性文件,其中有一个 key/value 对:

service.wsdl.url = https://myservice.com/testservice.asmx?wsdl

我想做这样的事情:

<properties>
    <service.wsdl.url>${service.wsdl.url}</service.wsdl.url>
</properties>

我已经检查了一些答案和帖子,但如前所述,我找不到满足我需要的东西。

任何帮助将不胜感激。

提前致谢!

您或许可以将 properties-maven-plugin 用作:

  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>properties-maven-plugin</artifactId>
    <version>1.0.0</version>
    <executions>
      <execution>
        <phase>initialize</phase>
        <goals>
          <goal>read-project-properties</goal>
        </goals>
        <configuration>
          <files>
            <file>src/main/resources/application.properties</file>
          </files>
        </configuration>
      </execution>
    </executions>
  </plugin>