日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

第4章 springboot热部署 4-1 SpringBoot 使用devtools进行热部署

發布時間:2023/11/30 javascript 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 第4章 springboot热部署 4-1 SpringBoot 使用devtools进行热部署 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

/imooc-springboot-starter/src/main/resources/application.properties

#關閉緩存, 即時刷新 #spring.freemarker.cache=false spring.thymeleaf.cache=true#熱部署生效 spring.devtools.restart.enabled=true #設置重啟的目錄,添加那個目錄的文件需要restart spring.devtools.restart.additional-paths=src/main/java # 為mybatis設置, 生產環境可刪除 #restart.include.mapper=/mapper-[\\w-\\.]+jar #restart.include.pagehelper=/pagehelper-[\\w-\\.]+jar #排除那個目錄的文件不需要restart spring.devtools.restart.exclude=static/**,public/**,WEB-INF/** #classpath目錄下的WEB-INF文件夾內容修改不重啟 #spring.devtools.restart.exclude=WEB-INF/**

/imooc-springboot-starter/pom.xml

<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.imooc</groupId><artifactId>imooc-springboot-starter</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>imooc-springboot-starter</name><description>Demo project for Spring Boot</description><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.0.6.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!-- 熱部署 --><!-- devtools可以實現頁面熱部署(即頁面修改后會立即生效,這個可以直接在application.properties文件中配置spring.thymeleaf.cache=false來實現) --><!-- 實現類文件熱部署(類文件修改后不會立即生效),實現對屬性文件的熱部署。 --><!-- 即devtools會監聽classpath下的文件變動,并且會立即重啟應用(發生在保存時機),注意:因為其采用的虛擬機機制,該項重啟是很快的 --><!-- (1)base classloader (Base類加載器):加載不改變的Class,例如:第三方提供的jar包。 --><!-- (2)restart classloader(Restart類加載器):加載正在開發的Class。 --><!-- 為什么重啟很快,因為重啟的時候只是加載了在開發的Class,沒有重新加載第三方的jar包。 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional><!-- optional=true, 依賴不會傳遞, 該項目依賴devtools;之后依賴boot項目的項目如果想要使用devtools, 需要重新引入 --></dependency> </dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

/imooc-springboot-starter/src/main/java/com/imooc/controller/UserController.java

package com.imooc.controller;import java.util.Date;//import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController;import com.imooc.pojo.LeeJSONResult; import com.imooc.pojo.User;//@Controller @RestController // @RestControler = @Controller + @ResponseBody @RequestMapping("/user") public class UserController {//@RequestMapping("/hello")@RequestMapping("/getUser")//@ResponseBodypublic User hello() {//public User getUser() { User u = new User();u.setName("imooc");u.setAge(18);u.setBirthday(new Date());u.setPassword("imooc");//u.setDesc(null);u.setDesc("hello imooc~~");return u;}@RequestMapping("/getUserJson")//@ResponseBodypublic LeeJSONResult hello1() {//public LeeJsonResult getUserJson() { User u = new User();//u.setName("imooc");u.setName("imooc1");u.setAge(18);u.setBirthday(new Date());u.setPassword("imooc");//u.setDesc(null);//u.setDesc("hello imooc~~");u.setDesc("hello imooc1~~");return LeeJSONResult.ok(u);} }

/imooc-springboot-starter/src/main/java/com/imooc/controller/UserController.java

package com.imooc.controller;import java.util.Date;//import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; //import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController;import com.imooc.pojo.LeeJSONResult; import com.imooc.pojo.User;//@Controller @RestController // @RestControler = @Controller + @ResponseBody @RequestMapping("/user") public class UserController {//@RequestMapping("/hello")@RequestMapping("/getUser")//@ResponseBodypublic User hello() {//public User getUser() { User u = new User();//u.setName("imooc");u.setName("imooc1");u.setAge(18);u.setBirthday(new Date());//u.setPassword("imooc");u.setPassword("imooc1");//u.setDesc(null);//u.setDesc("hello imooc~~");u.setDesc("hello imooc1~~");return u;}@RequestMapping("/getUserJson")//@ResponseBodypublic LeeJSONResult hello1() {//public LeeJsonResult getUserJson() { User u = new User();//u.setName("imooc");u.setName("imooc1");u.setAge(18);u.setBirthday(new Date());u.setPassword("imooc");//u.setDesc(null);//u.setDesc("hello imooc~~");u.setDesc("hello imooc1~~");return LeeJSONResult.ok(u);} }

?

轉載于:https://www.cnblogs.com/ZHONGZHENHUA/p/9868685.html

總結

以上是生活随笔為你收集整理的第4章 springboot热部署 4-1 SpringBoot 使用devtools进行热部署的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。