Having to restart tomcat whenever you make a change

后端 未结 8 954
名媛妹妹
名媛妹妹 2020-12-04 18:46

Is there a way around having to restart tomcat every time a small change is made in java code?

相关标签:
8条回答
  • 2020-12-04 18:48

    I've been using the Spring Loaded JVM agent to avoid restarting Tomcat or reloading the application (which can take a while for Spring web apps). I configure my Tomcat server in Eclipse along with "Automatically publish when resources change" to get changes to take effect nearly immediately.

    If you use Eclipse with Tomcat integrated (WTP), you can see the steps I took here: https://stackoverflow.com/a/37064672/1034436

    0 讨论(0)
  • 2020-12-04 18:49

    Set reloadable attribute of <Context> element in context.xml to true.

    <Context reloadable="true">
    

    Then Tomcat will monitor changes in /WEB-INF/classes and /WEB-INF/lib and reload whenever appropriate.

    If you're using an IDE, this is configureable as server setting as well. Here's how it look like in Eclipse:

    alt text

    0 讨论(0)
  • 2020-12-04 18:53

    If you need to modify classes without restarting consider Dynamic Code Evolution VM in addition to BalusC's answer to avoid permgen errors, for development.

    0 讨论(0)
  • 2020-12-04 18:53

    You can also try DCEVM. I have written a howto about how to setup with tomcat + eclipse: Spring-mvc + Velocity + DCEVM

    0 讨论(0)
  • 2020-12-04 18:58

    Yes. You can set tomcat to autodeploy and it will pick up the changes automatically. It still redeploys, but it's much faster. Just add "autodeploy="true"" to your Host entry in the server.xml config file.

    That's what we do where I work. When it's time to update one of our applications we just drop the new WAR file on top of the old one and Tomcat unpacks and deploys it automatically.

    0 讨论(0)
  • 2020-12-04 19:00

    Even if Tomcat is generally very fast on the startup, it depends very much on your application, how quickly it can initialize itself. If there is a damn big Spring application context, with all kinds of integrations and Hibernate mappings, I'd be pretty sure that the boot will take 1,5 seconds to start Tomcat, but 1,5 minutes to start your application. JRebel could really help here.

    0 讨论(0)
提交回复
热议问题