1.使用maven添加spring-boot-devtools依賴(spring-boot1.3 之後的版本擁有的新特性)java
<repositories>web
<repository>spring
<id>spring-milestones</id>服務器
<name>Spring Milestones</name>app
<url>http://repo.spring.io/milestone</url>eclipse
<snapshots>maven
<enabled>false</enabled>ide
</snapshots>spring-boot
</repository>測試
</repositories>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
2.在項目的application.properties中添加相應的配置
server.port 配置服務器訪問端口
spring.devtools.remote.secret 遠程熱部署口令 必需要有
3.使用maven 命令 mvn package 打包程序
4.在服務器上部署項目 命令爲java -jar ****.jar
5.在進行熱部署配置(奉獻上eclipse、Idea兩個版本的配置)
本地項目:
1)eclipse 版本
操做方式
run-->run configurations (以下圖)
apply --> run 啓動項目
2)Idea版本
run --> run --> edit configurations
點擊左上角+ 選中 Application
apply --> run 啓動項目
編譯方式兩者可能不一樣
其中eclipse 自動編譯,代碼改動後就會編譯
Idea 是 build --> rebuild project
控制檯 若是沒有報錯,而後就改動本地代碼,編譯,控制檯的日誌記錄會發生變化(未報錯),而後再去訪問服務器上的項目,發現本身改動的地方已經發生變化。就這麼簡單。
附上 spring-boot 測試代碼
package com.test; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * Create whit idea * Created by on 2016/3/24. * 13:37 */ @RestController @SpringBootApplication public class TestApplication { private String name="hello worldfffsdsfdddffd!"; @RequestMapping("/") public String getName(){ return name; } public static void main(String [] args){ SpringApplication.run(TestApplication.class,args); } }