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); } }