[英]batch file to edit a text file
我需要使用war文件來部署Web應用程序。
我已經解決了如何使用jar命令創建war文件。 但是,當用戶部署Web應用程序時,必須更新web.xml文件中的某些字符串以反映用戶環境。
例如在web.xml文件中,我有條目(示例):
<init-param>
<param-name>colour</param-name>
<param-value>red</param-value>
</init-param>
我想詢問用戶顏色,然后更新war文件。 顯然,這樣用戶可以部署正確的東西。 我可以使用jar uf更新文件-那里沒有問題。 例如,上面的文本將插入到文本文件中的設置位置。 具體而言,將在文本之后。
我很高興在命令行上執行此操作。 例如這樣的事情:
我將如何編程? 目前,僅Windows(但不久將需要Linux支持)。 批處理文件? 有關如何處理的任何建議?
按照本示例中的說明使用Maven資源過濾: http : //maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
@echo off&setlocal REM set the old color in a variable set "oldstring=red" REM prompt the user for a string set/p "string=enter string: " REM update string in web.xml sed -i "s/%oldstring%/%string%/i" web.xml type web.xml
..輸出為:
enter string: green
<init-param>
<param-name>colour</param-name>
<param-value>green</param-value>
</init-param>
我沒有war files
線索。 請解釋,然后我將改進我的代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.