spring boot: 熱部署spring-boot-devtoolsjava
1引入spring-boot-devtools依賴包web
<!-- spring boot devtools 熱部署 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <scope>true</scope> </dependency>
2.部署spring boot devtool pluginspring
<!-- 這是spring boot devtool plugin --> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!--fork : 若是沒有該項配置,肯呢個devtools不會起做用,即應用不會restart --> <fork>true</fork> </configuration> </plugin>
部署完成。apache
參考pom.xmljson
<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.muyang</groupId> <artifactId>boot1</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>boot1</name> <url>http://maven.apache.org</url> <!-- Inherit defaults from Spring Boot --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> <!--<version>2.0.1.RELEASE</version>--> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <!-- 自動依賴parent裏面的版本 <version></version> --> </dependency> <!-- dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency--> <!-- FastJson --> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.15</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <!-- spring boot devtools 熱部署 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <scope>true</scope> </dependency> </dependencies> <build> <finalName>boot1</finalName> <plugins> <!-- spring boot devtools的plugin --> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!--fork : 若是沒有該項配置,呢個devtools不會起做用,即應用不會restart --> <fork>true</fork> </configuration> </plugin> <!-- 在這裏添加springloader plugin 熱部署--> <!-- <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.4.RELEASE</version> </dependency> </dependencies> <executions> <execution> <goals> <goal>repackage</goal> </goals> <configuration> <classifier>exec</classifier> </configuration> </execution> </executions> </plugin> --> </plugins> </build> </project>
能夠訪問:http://localhost:8080/h4/getBookmaven
而後新增:http://localhost:8080/h4/getDemospring-boot