[英]Read a particular value xml file and replace values in property file using ant
Suppose I have an xml file like abc.xml which contains 假设我有一个像abc.xml这样的xml文件,其中包含
<datasource name="localmysql">
<inline-jdbc jdbc-driver="com.mysql.jdbc.Driver"
jdbc-uri="url"
jdbc-username="username" jdbc-password="password"/>
</datasource>
<datasource name="localmysqlolap">
<inline-jdbc jdbc-driver="com.mysql.jdbc.Driver"
jdbc-uri="url1"
jdbc-username="username1" jdbc-password="password1"/>
</datasource>
<datasource name="localmysqltenant">
<inline-jdbc jdbc-driver="com.mysql.jdbc.Driver"
jdbc-uri="url2"
jdbc-username="username2" jdbc-password="password2"/>
</datasource>
Now I want to read the values of jdbc-uri, jdbc-username, jdbc-password in node 现在我想读取节点中jdbc-uri,jdbc-username,jdbc-password的值
datasource name="localmysql"
and change the values of a property file which also contains jdbc-uri, jdbc-username, jdbc-password as keys. datasource name="localmysql"
并更改属性文件的值,该属性文件还包含jdbc-uri,jdbc用户名,jdbc密码作为键。 Is there a way to do it using ant 有没有办法用蚂蚁做
You can use ANT replace task and replace each value. 您可以使用ANT替换任务并替换每个值。 In this case you will need to know old/new properties values.
在这种情况下,您将需要知道旧的/新的属性值。
I used property regex task from ant-contrib 我使用了来自ant-contrib的 属性regex任务
Please remember, that properties in ANT are immutable and can't be modified/updated 请记住,ANT中的属性是不可变的,无法修改/更新
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.