In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to use spring-boot-devtools in spring-boot, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
1. What is spring-boot-devtools?
Spring-boot-devtools is a hot deployment tool for spring-boot project development. With spring-boot-devtools dependencies installed, we do not need mvn spring-boot:run to restart the spring-boot project manually after modifying the source code. Spring-boot-devtools will automatically restart the project for us. By default, spring-boot-devtools detects all files on the classpath of the project folder. Note that some resources, such as static assets and view templates, do not need to restart the project.
2. The use of spring-boot:run:
First, configure the dependency in the pom.xml file
Org.springframework.boot spring-boot-devtools
After the dependency is configured, the spring-boot-devtools toolkit will be downloaded automatically when the project is run. When we make changes to the file under the project path, click Save, which will trigger a restart.
Note that by default, changing / META-INF/maven, / META-INF/resources, / resources, / static, / public does not trigger a restart.
If you want to set these exclusions, you can set spring.devtools.restart.exclude in the applcation.properties file. For example, only all files under / static and / public are excluded:
Spring.devtools.restart.exclude=static/**,public/**
3. How do I disable restart?
1) set in application.properties
Spring.devtools.restart.enabled=false
2) completely disable restart support. You need to set spring.devtools.restart.enabled system properties.
Public static void main (String [] args) {System.setProperty ("spring.devtools.restart.enabled", "false"); SpringApplication.run (MyApp.class, args);}
Pay attention to stepping on the pit:
Before using eclipse to do spring-boot to do a web project, configured spring-boot-devtools dependency, there is no problem to open the project for the first time, and then habitually close the project to modify the code, click to start the project after modifying the code, and report an error: the port number is occupied.
This error is one of the most common errors when learning web, which can be solved by turning off the tomcat that is still on. In a web project configured with spring-boot, you need to configure the spring-boot-web dependency, which has a built-in tomcat, so under normal circumstances, we will automatically close the tomcat when we close the project directly, but an error is reported here!
Then I searched the Internet for a long time and found that it was the problem of spring-boot-devtools. I tried to disable hot deployment and found that it still didn't work (maybe it was my environmental problem, and some people on the Internet were successful). At this time, you can only open the terminal, enter: netstat-aon | findstr "8080" to view the process id (pid) that is occupying port 8080, then open the task manager and close the process (or enter the command directly in the terminal to close: taskkill / pid 4484-f4484 is the pid number occupying port 8080)
The above is all the content of the article "how to use spring-boot-devtools in spring-boot". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.