tags:

  • maven
  • jetty
  • idea
  • jrebel
  • java

Maven + Jetty + IDEA + JRebel enables hot deployment of projects

The development environment

During development: Modifying Java or project files requires reconstructing the project to build deploy, which takes an unbearably long time

How to implement hot deployment of all subsequent changes after one deployment?

  1. Implemented using JRebel
  2. The Web container uses Jetty
  3. Maven for project management
  4. The IDE uses IDEA

Implementation steps

  1. Go to Settings > Plugins in idea and search for JRebel –> Browse Repositories
  2. After the download is complete, apply the idea and restart it
  3. Because equal is charging software Break the link is as follows: http://blog.lanyus.com/archives/317.html after normal boot styles:

  1. For the project that needs hot deployment do the following right click on the project name and select JRebel to generate a profile. The correct profile should look like this:
<? xml version="1.0" encoding="UTF-8"? > <! -- This is the JRebel configuration file. It maps the running application to your IDE workspace, enabling JRebel reloadingfor this project.
  Refer to https://manuals.zeroturnaround.com/jrebel/standalone/config.html for more information.
-->
<application generated-by="intellij" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.zeroturnaround.com" xsi:schemaLocation="http://www.zeroturnaround.com http://update.zeroturnaround.com/jrebel/rebel-2_1.xsd">

	<classpath>
		<dir name="C:/workspaces***************/target/classes"> <! -- Compile path for the project --> </dir> </classpath> <web> <link target="/">
			<dir name="C:/workspace**********src/main/webapp"> <! -- For the project path --> </dir> </link> </web> </application>Copy the code
  1. On the menu bar of IDEA, select View > Tool to display both toolbars as follows:

<plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>jetty-maven-plugin</artifactId> < version > 8.1.16. V20140903 < / version > < configuration > < stopKey > stop < / stopKey > < stopPort > 9999 < / stopPort > <scanIntervalSeconds>0</scanIntervalSeconds><! -- Use jetty's own hot deployment: 1 does not have to be 0--> <contextXml>${project.basedir}/src/main/resources/jetty-context.xml</contextXml>
          <webApp>
            <contextPath>/</contextPath>
          </webApp>
          <connectors>
            <connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
              <port>8001</port>
              <maxIdleTime>60000</maxIdleTime>
            </connector>
          </connectors>
        </configuration>
      </plugin>
Copy the code
  1. When jRebel Debug is clicked and the launch log appears as shown below, the configuration is successful

  2. Hot deployment for a single file: CTRL + Shift + F9 Hot deployment for all modified files: CTRL + F9 Don’t forget CTRL + S before executing

  3. If the following information is displayed after the preceding command is executed, the deployment is successful:

Please do not reprint without author’s permission, thank you 🙂