Configuration method of Springboot hot deployment in IDEA

1 pom.xml file

Note: The hot deployment function has been available since spring-boot-1.3

  1. <!--Add dependency-->
  2. <dependency>
  3. <groupId>org.springframework.boot</groupId>
  4. <artifactId>spring-boot-devtools</artifactId>
  5. <!-- optional=true, the dependency will not be passed, the project depends on devtools; if the project that depends on the myboot project wants to use devtools, it needs to be re-introduced -->
  6. <optional>true</optional>
  7. </dependency> Zhejiang Surrogacy
copy code

Note: The spring-boot-maven-plugin is added to the project, which is mainly used in eclipse. This configuration does not need to be added to the idea.

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.springframework.boot</groupId>
  5. <artifactId>spring-boot-maven-plugin</artifactId>
  6. <configuration>
  7. <fork>true</fork>
  8. </configuration>
  9. </plugin>
  10. </plugins>
  11. </build>
copy code

2 Change the idea configuration Zhejiang Surrogacy Company

  1) “File” -> “Settings” -> “Build,Execution,Deplyment” -> “Compiler”,选中打勾 “Build project automatically” 。

  2) Key combination: "Shift+Ctrl+Alt+/", select "Registry", check "compiler.automake.allow.when.app.running".

3 Chrome disable cache

  F12 or "Ctrl+Shift+I", open the developer tools, select "Disable Cache(while DevTools is open)" under the "Network" tab

Replenish:

Intellij IDEA 4 ways to configure hot deployment

Hot deployment makes it possible to load the changed code without restarting the server after modifying the code.

Type 1: Modify the server configuration so that when the IDEA window loses focus, update classes and resources

Menu Run -> EditConfiguration , and then configure the specified server, on frame deactivation = Update classes and resource under the server tab on the right.

Pros: Simple

Disadvantages: Hot loading based on JVM only supports code modification in method blocks, only in debug mode, and when idea loses focus, hot loading will start, and the relative loading speed is slow

Type 2: Use springloaded jar package

a. 下载jar包,github:https://github.com/spring-projects/spring-loaded

b. Add VM startup parameters when starting the application: -javaagent:/home/lkqm/.m2/repository/org/springframework/springloaded/1.2.7.RELEASE/springloaded-1.2.7.RELEASE.jar -noverify

Advantages: good support for Spring series frameworks (excluding Spring boot), support for member-level modifications (add, delete, and modify methods, fields, annotations), and support for enumeration value sets.

Disadvantages: as opposed to advantages

Type 3: Use the developer tools provided by spring-boot-devtools

The following dependencies are introduced into the spring-boot project

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-devtools</artifactId>
  4. </dependency>
copy code

Advantages: Simple, supports Spring-boot projects, and supports hot deployment of member-level modifications.

Disadvantage: Only supports spring-boot projects.

Type 4: Use the Jrebel plug-in to achieve hot deployment (the plug-in is a 14-day free trial)

Online installation: Menu File -> Setting -> Plugin, click Browse repositories at the bottom right, enter: JReble for Intellij at the top of the pop-up box, and select Install.

Advantages: Powerful, supports various frameworks, and provides IDE plug-ins.

The last three methods are based on the class loading mechanism to achieve hot loading. Therefore, after you modify the code, you must recompile the current code to trigger hot deployment. Eclipse supports automatic compilation by default, while in Intellij IDEA, automatic compilation is turned off by default. Compiled, you can set it up according to the following 2 steps:

  1. IDEA enables automatic project compilation, enter settings, Build, Execut, Deployment -> Compiler Check the Build Project automatically on the left
  2. IDEA enables automatic make when the project is running, ctrl + shift + a search command: registry -> check compiler.automake.allow.when.app.running

Summarize

The above is the configuration method of Springboot hot deployment in IDEA introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325235276&siteId=291194637