zoukankan      html  css  js  c++  java
  • nacos作为配置中心的简单项目配置

    配置中心(nacos)

    github地址

    中文文档

    一、接入项目

    1、依赖

     <dependency>
         <groupId>com.alibaba.cloud</groupId>
         <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
     </dependency>
    

    2、bootstrap.properties

    spring.application.name=nacos-config-example
    spring.cloud.nacos.config.server-addr=127.0.0.1:8848 # 配置中心服务地址
    

    3、application.yml

    spring:
      cloud:
        nacos:
          config:
            server-addr: 127.0.0.1:8848 # nacos-server 地址
      application:
        # 项目名称
        name: nacos-config-example # 项目名称
        
    demo:
      user:
        name: zhangsan
        age: 18
    

    4、@RefreshScope、@Value("${}")

    //  @RefreshScope 打开动态刷新功能
    @RefreshScope
    class SampleController {
    
        // @Value 注解来将对应的配置注入到 SampleController 的 userName 和 age 字段
    
        @Value("${demo.user.name}")
        String userName;
    
        @Value("${demo.user.age}")
        int age;
    }
    

    5、控制台

    控制台 -- 配置管理 -- 配置列表中,完成相应配置即可。

  • 相关阅读:
    Cocos2d-html5 笔记2: director
    Cocos2d html5 笔记 1: overview
    Device Pixel Ratio & Media Queries
    Viewport
    Viewport解决分辨率适配问题
    Ajax缓存解决办法
    capitalize()
    chr() 、ord()
    oct()
    eval()
  • 原文地址:https://www.cnblogs.com/luckyzs/p/13167901.html
Copyright © 2011-2022 走看看