Spring Boot Remote Application

Spring Boot 1.4.2

Eclipse

Spring Boot支持远程代码更新和远程debug。

远程代码更新的意思是,在本地IDE修改代码,可以自动更新到服务器上,并且自动重启生效。就像在本地开发环境一样。

 

远程应用的实现有两个component,server component是run在服务器端,client component是run在本地。

要开启此功能,需要修改pom,重新打包,并把新包部署到服务器上。

 

 


<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <excludeDevtools>false</excludeDevtools> </configuration> </plugin> </plugins> </build>

并且在spring的启动配置文件application.properties中增加spring.devtools.remote.secret=xxx配置,启动应用后,server component就会开启。

Client component需要在Eclipse中启动。创建一个run configuration,main class为org.springframework.boot.devtools.RemoteSpringApplication,并把server的http://hostname:port(这里建议使用https)作为Program arugments。

RemoteSpringApplication启动以后,在本地修改代码,client端log会有类似如下内容,

2017-03-15 14:21:05.976  INFO 5317 --- [   File Watcher] o.s.b.d.r.c.ClassPathChangeUploader      : Uploaded 2 class resources
2017-03-15 14:21:25.751  INFO 5317 --- [pool-1-thread-1] o.s.b.d.r.c.DelayedLiveReloadTrigger     : Remote server has changed, triggering LiveReload

 服务器端会自动重启,并生效新代码。

 

 

远程debug,首先服务端启动时要增加-Xdebug -Xrunjdwp:server=y,transport=dt_socket,suspend=n JVM参数。

在Eclipse中创建一个debug configuration,在Remote Java Application中增加一个新的configuration,地址为localhost,端口为8000。

增加断点,访问服务端服务,断点就会触发。实际上是client component启动了8000端口,所以Remote Java Application中的地址为本机地址localhost,而并不是服务器端的地址。

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值