如何在朗姆酒时间从Java文件将值传递给Maven pom.xml? [英] How to pass value to maven pom.xml at rum time from java file?

查看:111
本文介绍了如何在朗姆酒时间从Java文件将值传递给Maven pom.xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java文件,其中的变量在运行时取值.我使用Web服务发现来搜索服务并将其URL保留在变量中. 现在,我需要将此值传递给pom.xml.

I have a java file where a variable taken value at run time.I search for a service using web service discovery and keep its url in a variable. Now I need to pass this value to pom.xml.

abc.java的代码为

abc.java has code with

String url= http://xx.xx.xx.xx:55939/ABCDevice?wsdl

Pom.xml是:

<wsdlOptions>
           <wsdlOption>
           <wsdl>url</wsdl> <!-- get urlvalue from java file -->
            <wsdlLocation>classpath:com/admin/discovery/ABCService.wsdl
                </wsdlLocation>
            </wsdlOption>
            </wsdlOptions>

在wsdl中,我想传递字符串值" http://xx.xx.xx .xx:55939/ABCDevice?wsdl ",只有在运行时才能确定.

In wsdl i want to pass string value "http://xx.xx.xx.xx:55939/ABCDevice?wsdl" which is determined only after run time.

我该怎么办?

推荐答案

我不认为这是Apache Maven的特定问题,而是一般的Java问题(Maven可能使您意识到了). 在构建期间,您不知道该使用什么url.根据应用程序的类型,您有几种选择:

I don't consider this as an Apache Maven specific issue, but a general Java issue (Maven probably made you aware of it). During build-time you have no idea what the url should be. Depending on the type of application you have several options:

  • JNDI(如果是Web容器)
  • 预定义位置上的属性文件
  • 系统属性
  • 作为参数(如果是可执行jar)
  • 在部署之前调整web.xml(某些Web容器可以帮助您解决此问题)
  • ...

在使用像Spring这样的框架时,可以通过简单的方法来注入上面的选项之一.

In you use a framework like Spring there are easy ways to inject one the options above.

这篇关于如何在朗姆酒时间从Java文件将值传递给Maven pom.xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆