SpringBoot热部署之devtools案例(学习笔记)
声明:本案例学习http://blog.csdn.net/je_ge,在此感谢je_ge提供的学习用的资料
1、项目目录结构
2、pom.xml的内容
<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/maven-v4_0_0.xsd"><modelVersion>4.0.0modelVersion><groupId>com.jege.spring.bootgroupId><artifactId>spring-boot-devtoolsartifactId><packaging>warpackaging><version>1.0.0.RELEASEversion><name>spring-boot-mybatisname><url>http://blog.csdn.net/je_geurl><developers><developer><id>je_geid><name>je_gename><email>1272434821@qq.comemail><url>http://blog.csdn.net/je_geurl><timezone>8timezone>developer>developers><parent><groupId>org.springframework.bootgroupId><artifactId>spring-boot-starter-parentartifactId><version>1.4.1.RELEASEversion><relativePath />parent><properties><project.build.sourceEncoding>UTF-8project.build.sourceEncoding><java.version>1.8java.version>properties><dependencies><dependency><groupId>org.springframework.bootgroupId><artifactId>spring-boot-starter-webartifactId>dependency><dependency><groupId>org.springframework.bootgroupId><artifactId>spring-boot-devtoolsartifactId><optional>trueoptional>dependency>dependencies><build><finalName>spring-boot-devtoolsfinalName><plugins><plugin><groupId>org.springframework.bootgroupId><artifactId>spring-boot-maven-pluginartifactId><configuration>configuration>plugin><plugin><groupId>org.apache.maven.pluginsgroupId><artifactId>maven-compiler-pluginartifactId><configuration><source>${java.version}source><target>${java.version}target>configuration>plugin>plugins>build>
project>
3、application.properties的内容
#添加那个目录的文件需要restart
spring.devtools.restart.additional-paths=src/main/java
#排除那个目录的文件不需要restart
spring.devtools.restart.exclude=static/**,public/**
4、HelloController的内容
package com.jege.spring.boot.devtools;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;/*** @author JE哥* @email 1272434821@qq.com* @description:看看devtools模块的快速*/
@RestController
public class HelloController {@RequestMapping("/hello")public String hello() {// System.out.println("test");return "Hello World";}
}
5、Application的内容
package com.jege.spring.boot;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;/*** @author JE哥* @email 1272434821@qq.com* @description:spring boot 启动类*/@SpringBootApplication
public class Application {public static void main(String[] args) {SpringApplication.run(Application.class, args);}}
浏览器中输入:
http://localhost:8080/hello
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
