Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven + Tomcat hot deploy

I've searched on the internet for this question and found no single solution. We have a maven project that uses profiles to build artifact that suits dev/qa/prod environtments, does minification of JS and CSS using YUI plugin. It uses Spring for dependency injection and struts as UI framework. Ibatis is used as ORM mapper. We use Eclipse IDE on windows and are not using integrated eclipse as we need to deploy Unix servers. Now, my question is, is there a way to deploy this solution in such a way that changes to js, css, jsp, applicationContext files of spring, struts.xml, ibatis mapper files and of course Java code to take immediate effect without server restart. I remember spring-groovy plugin supports reload of context for a change in groovy file. So, I presume there should be a way supports hot deploy too.

like image 645
Gopal Avatar asked Mar 02 '26 22:03

Gopal


1 Answers

I find that maven tomcat plugin is slow because it always use the tomcat's client deployer and deploys by the http calls on the manager like localhost:8080/manager/text

Tomcat has a web application reloading mechanism managed by "autoDeploy" that you can read about it here. So being that it reloads whenever the application war is changed I have made the following change to my maven-war-plugin:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <outputDirectory>${my.tomcat.path}</outputDirectory>
    </configuration>
</plugin>

where

<properties>
    <my.tomcat.path>[MY TOMCAT WEBAPP PATH]</my.tomcat.path>
</properties>

After this I only need to do mvn compile war:war or mvn compile package

like image 162
CaughtOnNet Avatar answered Mar 04 '26 10:03

CaughtOnNet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!