如何在一个 pom.xml - Maven 中区分不同的 wsdl 位置
How to distinguish between different wsdl locations in one pom.xml - Maven
是否可以在 maven 中区分 wsdl web 服务的多个配置?
我有 one application
,可以 运行 test, stage and prod environments
。而且我必须使用一个网络服务。网络服务有 3 different wsdl locations
。对于 test, stage and prod.
maven 中是否有一种方法可以说明如果我想为产品构建我的应用程序,只需使用产品的 Web 服务位置。阶段和测试也一样吗?
我有一个 wsdl 导入配置,它适用于单个非动态部分。
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>wsdlFile_live.wsdl</wsdlFile>
</wsdlFiles>
<vmArgs>
<vmArg>-Djavax.xml.accessExternalDTD=all</vmArg>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
<packageName>com.example.schema</packageName>
<wsdlLocation>http://liveLocation/?wsdl</wsdlLocation>
</configuration>
<id>wsimport-generate-_live.wsdl</id>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
<configuration>
<sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
<xnocompile>true</xnocompile>
<verbose>true</verbose>
<extension>true</extension>
<catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
</configuration>
您可以使用环境变量来存储您的 wsdl 文件并传递给 maven 系统属性。例如,在 Linux 上你想访问环境变量 MY_VARIABLE。您可以在 pom 文件中使用系统 属性。
<properties>
...
<!-- Default value for my.variable can be defined here -->
<my.variable>foo</my.variable>
...
...
${my.variable}
在maven命令行设置属性值:
mvn clean package -Dmy.variable=$MY_VARIABLE
在 maven 中创建配置文件是构建具有不同范围的不同应用程序的一种可能性。
<profiles>
<profile>
<id>prod</id>
<build>
....
</build>
</profile>
<profile>
<id>test</id>
<build>
....
</build>
</profile>
</profiles>
在配置文件 属性 中,您可以设置 dependencies、resourves、plugins、配置等等。
要构建特定的个人资料,您必须键入 mvn -P
,然后输入 个人资料 ID
在我的例子中,它看起来像这样:mvn -Ptest clean install
或 mvn -Pprod clean install
是否可以在 maven 中区分 wsdl web 服务的多个配置?
我有 one application
,可以 运行 test, stage and prod environments
。而且我必须使用一个网络服务。网络服务有 3 different wsdl locations
。对于 test, stage and prod.
maven 中是否有一种方法可以说明如果我想为产品构建我的应用程序,只需使用产品的 Web 服务位置。阶段和测试也一样吗?
我有一个 wsdl 导入配置,它适用于单个非动态部分。
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>wsdlFile_live.wsdl</wsdlFile>
</wsdlFiles>
<vmArgs>
<vmArg>-Djavax.xml.accessExternalDTD=all</vmArg>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
<packageName>com.example.schema</packageName>
<wsdlLocation>http://liveLocation/?wsdl</wsdlLocation>
</configuration>
<id>wsimport-generate-_live.wsdl</id>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>2.0.1</version>
</dependency>
</dependencies>
<configuration>
<sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
<xnocompile>true</xnocompile>
<verbose>true</verbose>
<extension>true</extension>
<catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
</configuration>
您可以使用环境变量来存储您的 wsdl 文件并传递给 maven 系统属性。例如,在 Linux 上你想访问环境变量 MY_VARIABLE。您可以在 pom 文件中使用系统 属性。
<properties>
...
<!-- Default value for my.variable can be defined here -->
<my.variable>foo</my.variable>
...
...
${my.variable}
在maven命令行设置属性值:
mvn clean package -Dmy.variable=$MY_VARIABLE
在 maven 中创建配置文件是构建具有不同范围的不同应用程序的一种可能性。
<profiles>
<profile>
<id>prod</id>
<build>
....
</build>
</profile>
<profile>
<id>test</id>
<build>
....
</build>
</profile>
</profiles>
在配置文件 属性 中,您可以设置 dependencies、resourves、plugins、配置等等。
要构建特定的个人资料,您必须键入 mvn -P
,然后输入 个人资料 ID
在我的例子中,它看起来像这样:mvn -Ptest clean install
或 mvn -Pprod clean install