博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java b2b2c shop 多用户商城系统源码- config 修改配置
阅读量:7041 次
发布时间:2019-06-28

本文共 1241 字,大约阅读时间需要 4 分钟。

访问接口修改

refresh

post方式执行http://localhost/refresh 会刷新env中的配置

restart

如果配置信息已经注入到bean中,由于bean是单例的,不会去加载修改后的配置

需要通过post方式去执行http://localhost/restart,

需要通过application.properties中配置endpoints.restart.enabled=true启动指定的端口

弊端: 通过restart耗时比较长,因此就有了RefreshScope

需要JAVA Spring Cloud大型企业分布式微服务云构建的B2B2C电子商务平台源码 一零三八七七四六二六

RefreshScopepackage com.lkl.springcloud.config.client;import org.springframework.beans.factory.annotation.Value;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.EnableAutoConfiguration;import org.springframework.cloud.context.config.annotation.RefreshScope;import org.springframework.context.annotation.ComponentScan;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;/** * Created by liaokailin on 16/4/28. */@EnableAutoConfiguration@ComponentScan@RestController@RefreshScopepublic class Application {    @Value("${name:World!}") String name ;    @RequestMapping("/")    public String home(){        return "Hello " + name;    }    public static void main(String[] args) {        SpringApplication.run(Application.class,args);    }}复制代码

在执行refresh时会刷新bean中变量值。

转载于:https://juejin.im/post/5c47c34a5188252538064d01

你可能感兴趣的文章
ES6入门---let和const
查看>>
Codepen 每日精选(2018-4-10)
查看>>
git学习笔记
查看>>
Thinking——Debian On Windows初试
查看>>
看完你也想编写自己的 react 插件
查看>>
记录一次并发读取MongoDB的踩坑过程
查看>>
初识JavaScript EventLoop
查看>>
MVC是什么
查看>>
关于 emotion 初步使用的笔记
查看>>
PHP 怎样在同一个域名下两个不同的项目做独立的登录机制?
查看>>
SpringCloud(第 005 篇)电影微服务,注册到 EurekaServer 中,通过 Http 协议访问用户微服务...
查看>>
k-邻近算法(kNN)
查看>>
gulp基础和常用插件介绍
查看>>
开发之路(设计模式六:命令模式上)
查看>>
JavaScript:并发模型与Event Loop
查看>>
CSS揭秘之《条纹背景》
查看>>
获得字符串包含↵,渲染到页面不换行的解决办法
查看>>
北哥这篇文讲解yii2权限扩展(yii2-admin) - 下部
查看>>
微信web开发遇到的坑
查看>>
写了一个数字转成简 / 繁体汉字的助手函数
查看>>