美文网首页
java b2b2c shop 多用户商城系统源码- confi

java b2b2c shop 多用户商城系统源码- confi

作者: IT小跑兵 | 来源:发表于2019-01-23 11:23 被阅读5次

访问接口修改
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电子商务平台源码 一零三八七七四六二六

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 shop 多用户商城系统源码

相关文章

网友评论

      本文标题:java b2b2c shop 多用户商城系统源码- confi

      本文链接:https://www.haomeiwen.com/subject/ecdjjqtx.html