问题
I have key.txt file in E:/ drive and app.war file in C:/ drive. How to copy key.txt to the subfolder of the app.war file i.e WebContent/WEB-INF. Key should copy to the WEB-INF folder. I want result like(after unzipping war file)
WebContent
|
|->META-INF
|->WEB-INF
|
|->key.txt
回答1:
Finally i got answer, for this i used.
mkdir c:/WEB-INF
cd WEB-INF
xcopy D:/key.txt C:/WEB-INF
jar uvf app.war /WEB-INF/key.txt
No need of unzipping and again zipping.
回答2:
You can use the jar
command to extract and re-create your WAR file:
mkdir mywar
cd mywar
jar -xf c:\path\to\mywar.war
copy c:\path\to\key.txt WEB-INF\
jar -cf c:\path\to\mynewwar.war .
回答3:
If you are building the war file in the first place, presumably with a build tool such as Ant, Maven, or Gradle, then you should bundle it in at build time using that tool.
If you really have to add the file after the fact, then you can take advantage of the fact that a .war file is really just a .zip file. Unzip it, add key.txt in the desired location, and then zip it back up.
来源:https://stackoverflow.com/questions/23154698/how-to-add-txt-file-to-the-war-archive-using-command-line-in-ms-windows