javatomcatwarweb-inf

how to change a file in web-inf/classes directory in war without unpacking?


here is the structure of my war file.

MyApp.war
      WEB-INF
          classes/com/info/App.java
          classes/application.properties
          lib/
      META-INF
      test  

just before deployment of this war to tomcat, Ops team will need to update the application.properties file.

I prefer not to explode. but just to update the war and leave for tomcat to explode during start up

I tried this

jar uvf MyApp.war /var/data/prod/application.properties

After I executed this command, I see a new file being added at root level of MyApp.war. but I want WEB-INF/classes/application.properties to be replaced this one. How can I do it.


Solution

  • I don't believe that it is the good approach anyway, you should externalize your configuration file as it will change from one env to another, so it should not be part of your archive. You should adapt your code to be able to read the configuration of your application from an external folder. Your Ops team will then have the same war to deploy on all env instead of one per env, which is much less error prone.