java B2B2C Springcloud电子商务平台源码- config 修改配置

简介: 在git端修改配置后如何让客户端生效? 需要JAVA Spring Cloud大型企业分布式微服务云构建的B2B2C电子商务平台源码 壹零叁八柒柒肆六二六访问接口修改refreshpost方式执行http://localhost/refresh 会刷新env中的配置restart如果配置信息已经注.

在git端修改配置后如何让客户端生效?

需要JAVA Spring Cloud大型企业分布式微服务云构建的B2B2C电子商务平台源码 一零三八七七四六二六
访问接口修改
refresh
post方式执行http://localhost/refresh 会刷新env中的配置
restart
如果配置信息已经注入到bean中,由于bean是单例的,不会去加载修改后的配置
需要通过post方式去执行http://localhost/restart,
需要通过application.properties中配置endpoints.restart.enabled=true启动指定的端口
弊端: 通过restart耗时比较长,因此就有了RefreshScope

RefreshScope
package 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
@RefreshScope
public 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中变量值。
java B2B2C Springcloud电子商务平台源码

目录
相关文章
|
1月前
|
Java 数据库连接 开发工具
web后端-SpringCloud-Config分布配置
web后端-SpringCloud-Config分布配置
|
2月前
|
API
在vite.config.js 配置代理
在vite.config.js 配置代理
68 2
|
8天前
|
JavaScript
vue.config.ts配置环境变量
vue.config.ts配置环境变量
14 0
|
1月前
|
移动开发 监控 小程序
mPaaS常见问题之uniapp ios端云打包的配置config文件如何解决
mPaaS(移动平台即服务,Mobile Platform as a Service)是阿里巴巴集团提供的一套移动开发解决方案,它包含了一系列移动开发、测试、监控和运营的工具和服务。以下是mPaaS常见问题的汇总,旨在帮助开发者和企业用户解决在使用mPaaS产品过程中遇到的各种挑战
26 0
|
1月前
|
消息中间件 SpringCloudAlibaba Java
【Springcloud Alibaba微服务分布式架构 | Spring Cloud】之学习笔记(八)Config服务配置+bus消息总线+stream消息驱动+Sleuth链路追踪
【Springcloud Alibaba微服务分布式架构 | Spring Cloud】之学习笔记(八)Config服务配置+bus消息总线+stream消息驱动+Sleuth链路追踪
782 0
|
1月前
|
开发工具 git 微服务
【二十三】搭建SpringCloud项目六(Config)配置中心动态刷新
【二十三】搭建SpringCloud项目六(Config)配置中心动态刷新
19 0
|
1月前
|
Java 开发工具 git
【二十二】搭建SpringCloud项目六(Config)配置中心
【二十二】搭建SpringCloud项目六(Config)配置中心
32 0
|
1月前
|
Java Nacos Sentinel
Spring Cloud Alibaba 面试题及答案整理,最新面试题
Spring Cloud Alibaba 面试题及答案整理,最新面试题
200 0
|
1月前
|
SpringCloudAlibaba Java 持续交付
【构建一套Spring Cloud项目的大概步骤】&【Springcloud Alibaba微服务分布式架构学习资料】
【构建一套Spring Cloud项目的大概步骤】&【Springcloud Alibaba微服务分布式架构学习资料】
145 0
|
1月前
|
SpringCloudAlibaba Java 网络架构
【Springcloud Alibaba微服务分布式架构 | Spring Cloud】之学习笔记(七)Spring Cloud Gateway服务网关
【Springcloud Alibaba微服务分布式架构 | Spring Cloud】之学习笔记(七)Spring Cloud Gateway服务网关
98 0