1 pom.xml file
Note: The hot deployment function spring-boot-1.3 has started
<!--Add dependency--><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <!-- optional=true, the dependency will not be passed, the project depends on devtools; if the project that depends on myboot project wants to use devtools, it needs to be reintroduced--> <optional>true</optional></dependency>
Note: Adding spring-boot-maven-plugin in project is mainly used in eclipse, and this configuration is not required to be added in idea.
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> </configuration> </plugin> </plugins></build>
2 Change idea configuration
1) "File" -> "Settings" -> "Build,Execution,Deplyment" -> "Compiler", check "Build project automatically".
2) Key combination: "Shift+Ctrl+Alt+/", select "Registry", and select "compiler.automake.allow.when.app.running".
3 Chrome disables cache
F12 or "Ctrl+Shift+I", open the developer tool, and select "Disable Cache(while DevTools is open)" under the "Network" tab.
Replenish:
Intellij IDEA 4 ways to configure hot deployment
After hot deployment, you can modify the code, you can load the changed code without restarting the server.
Type 1: Modify the server configuration so that the IDEA window loses focus, update the classes and resources
Menu Run -> EditConfiguration , then configure the specified server under the server tag on frame deactivation = Update classes and resource.
Advantages: Simple
Disadvantages: Hot loading based on JVM only supports code modification in method blocks. It only takes a hot load when the idea loses focus, and the relatively slow loading speed
Type 2: Use springloaded jar package
a. Download the jar package, 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: It supports Spring series frameworks well (excluding Spring boot), supports member-level modification (addition and deletion methods, fields, annotations), and supports enumeration value sets.
Disadvantages: Compared with advantages
Type 3: Use the developer tools provided by spring-boot-devtools
The following dependencies are introduced in the spring-boot project
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency>
Advantages: Simple, supports Spring-boot projects, and supports member-level modification hot deployment.
Disadvantages: Only support spring-boot projects.
Type 4: Use the Jrebel plug-in to achieve hot deployment (the plug-in is free for 14 days)
Online installation: Menu File -> Setting -> Plugin, click on the bottom of the right Browse repositories, 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 before it can trigger hot deployment. Eclipse supports automatic compilation by default, while in Intellij IDEA, automatic compilation is turned off by default. You can enable it in the following 2 steps:
Summarize
The above is the configuration method of Springboot in IDEA hot deployment introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!