logo

Maven Embedded Tomcat automatic redeploy

How to automatically redeploy embedded Tomcat if you change some Java class?

If you run embedded Tomcat using goal tomcat7:run, you will notice that when you change some Java class (for example a Servlet), the application won't automatically redeploy, so you will have to stop the whole server and run it again.

 

To change that go to pom.xml and add this configuration to the tomcat plugin:

 

<configuration>
  <contextFile>src/main/webapp/META-INF/context.xml</contextFile>
</configuration>

 

Next create a context.xml file:

 

<Context reloadable="true" backgroundProcessorDelay="1">
</Context>

 

And finally restart the server. And now if you change something in some Java class, the Tomcat will redeploy the application automatically.

 

 

Also if you use STS (Spring Tool Suite), in latest versions you have this Relaunch button, which will restart the server.

 


comments powered by Disqus

rss

Free online Java web application examples

Want to develop whole web applications which use database, security and more? See my github account, where are lot's of example projects:
github

Search