Friday, 29 June 2018

How to update a spring xml in war without rebuild

Spring Framework overview

Spring makes it easy to create Java enterprise applications. It provides everything you need to embrace the Java language in an enterprise environment, with support for Groovy and Kotlin as alternative languages on the JVM, and with the flexibility to create many kinds of architectures depending on an application’s needs.

Scenario

Suppose your software uses the spring framework via xml files and a spring xml file is contained in a jar inside the war package in lib folder but this file must be fixed.
It's possible update the file xml without a new build because this file during build stage is not compiled (as all xml files) but just moved into jar.
As first step, we need extract the war package to extract the jar using the command below:
 jar -xvf my-web-app-1.0.war
Now in our file system we have the war package and Its contents.
To simplify I suggest you move the jar to another folder.
Suppose the spring xml inside the jar in META-INF folder. So we reproduce (into path location of jar target) the same folder structure and use the following command:
 jar -uf my-jar-1.0.jar META-INF/my-spring-conf.xml
Now the jar contains the xml file updated.
The last step is the update of war package. Similarly to jar update, into path location of war target, we create a folder with lib name and put the jar updated and use the following command:
 jar -uvf my-web-app-1.0.war lib/my-jar-1.0.jar
Now the war package contains the spring xml with the update ant it is ready for the deploy into the application server.

No comments:

Post a Comment

Welcome

Hello everybody, Welcome in my blog called "Information technology archive". Obviously the topics will be related to Informatio...