SpringBoot thymeleaf eclipse Hot Deployment Scenario Operation Steps

  • 2021-07-06 10:49:39
  • OfStack

I found a lot of springboot hot deployment schemes on the Internet and tried several methods. Here is my successful scheme to share with you

Operating steps

1. Add hot deployment dependencies to pom


 <dependency>
   <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-devtools</artifactId>
       <optional>true</optional>
     </dependency>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
 </dependency>

2. Add plug-ins


<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
  <fork>true</fork>
</configuration>

3. Add background jump to 3. controller


 @RequestMapping(value = "/index",method = RequestMethod.GET)
  public String hello(Model model) {
    model.addAttribute("name", "Dear");
    return "index";
  }

4.index.html


<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <title> Shenzhou Taiyue Credit Information System </title>
</head>
<body>helloword!
<p th:text="'Hello ! , ' + ${name} + '!'" >3333</p>
 Test hot deployment 1111111
</body>
</html>

5. thymeleaf:


    mode: HTML5
    encoding: UTF-8
    content-type: text/html
   # Turn off caching at development time , Otherwise, you can't see the real-time page 
    cache: false
    cache-period: 0
  template:
      cache: false

6. Turn on automatic compilation

STEP 7 Test

Summarize


Related articles: