首页 > 编程语言 > 详细

springboot热更新

时间:2019-02-04 10:22:49      阅读:270      评论:0      收藏:0      [点我收藏+]

在代码开发过程中 经常需要在不重启项目的情况下 动态更新代码或者配置文件

下面我们来看看 具体应该怎么操作

pom.xml

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtool</artifactId>
</dependency>

 

配置文件 application.properties

server.port:8080
url:http://localhost

  

WebController

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WebController {
    @Autowired
    private Environment env;

    @RequestMapping("/getUrl")
    public String test(){
        return env.getProperty("url");
    }

}

 

以这种方式同样可以更新代码

 

springboot热更新

原文:https://www.cnblogs.com/lnas01/p/10351436.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!