首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在maven-jaxb2-plugin中外部配置WSDL位置

在maven-jaxb2-plugin中外部配置WSDL位置
EN

Stack Overflow用户
提问于 2017-06-22 22:46:06
回答 1查看 883关注 0票数 0

我正在尝试在Java应用程序中调用外部SOAP服务。为此,我希望从某个域上公开的wsdl生成请求和响应对象。我使用maven-jaxb2-plugin来做这件事:

代码语言:javascript
复制
<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.13.1</version>
        <executions>
            <execution>
                <goals>
                    <goal>generate</goal>
                </goals>
            </execution>
        </executions>
    <configuration>
        <schemaLanguage>WSDL</schemaLanguage>
        <generatePackage>example.wsdl</generatePackage>
        <schemas>
            <schema>
                <url>http://someaddress/example.wsdl</url>
            </schema>
        </schemas>
    </configuration>
</plugin>

问题是:我希望能够根据应用程序将要部署到的环境来更改WSDL (http://someaddress/example.wsdl)。我正在考虑使用系统属性来实现这一点,但是有没有更好的实践来实现这一点呢?

编辑:经过更多的搜索,我发现了一个类似的问题,但在C#上下文中。这是否有助于提出解决方案?How can you use two WSDLs and maintain a test instance with a C# application?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-22 23:44:49

使用Maven profiles

配置示例如下:

代码语言:javascript
复制
<!-- Profile configuration -->
<profiles>
    <!-- The configuration of the development profile -->
    <profile>
        <id>dev</id>
        <!-- The development profile is active by default -->
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
          <build.profile.url>http://someaddress/example.wsdl</build.profile.url>
        </properties>
    </profile>
    <!-- The configuration of the production profile -->
    <profile>
        <id>prod</id>
        <properties>
         <build.profile.url>http://someaddress/example2.wsdl</build.profile.url>
        </properties>
    </profile>
    <!-- The configuration of the testing profile -->
    <profile>
        <id>test</id>
        <properties>
           <build.profile.url>http://someaddress/example3.wsdl</build.profile.url>
        </properties>
    </profile>
</profiles>

然后在你的插件中

代码语言:javascript
复制
<schemas>
        <schema>
            <url>${build.profile.url}</url>
        </schema>
    </schemas>

要使用配置文件dev安装工件,请使用

代码语言:javascript
复制
mvn clean install -P dev
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44702717

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档