Spring Boot Hot Switch Configuration under Intellij IDEA
Believe that many people own Baidu"Idea spring boot hot deployment"
The solutions found are as follows:
1. Project Addition Dependencespring-boot-devtools
2.IDEA pressctrl+alt+s
——Build,Excution,Deployment
——Compiler
— SelectionBuild project automatically
3.IDEA pressctrl+shift+a
– inputregistry
——Compiler
— Selectioncompiler.automake.allow.when.app.running
But in fact, is too laggy, and every time you change a little bit of code, it will trigger IDEA to recompile, IDEA will become stuck, and development experience will be bad.
In fact, IDEA provides a pair ofspring-boot-devtools
Corresponding support, openIDEA——Help
Enter in the pop-up pagespring boot
You can find the document Configure application update policies with devtools.
Actual operation:
1. Introduce dependencies into your spring boot projectspring-boot-devtools
2. Find the main method and run the project.Note that you must run it by clicking main method
And not throughmvn spring-boot:run
orgradle bootRun
As follows:
3. After running, we can open it.Run
——Edit Configurations
InSpringBoot
Lower setupOn Update action
byUpdate classes and resources
As follows:
4. After setting up, run through main method, or click Run icon in menu bar, as shown in figure:
5. When we modify the code, IDEA will not automatically compile and restart SpringBoot. Instead, we need to click on the bottom left corner.Run
ColumnUpdate xxx application
Thermal switching will be triggered. Of course, we can also use shortcuts.ctrl+F10
。 The following picture: