美文网首页
springboot配置及多环境切换

springboot配置及多环境切换

作者: KenChen_939 | 来源:发表于2024-04-22 17:08 被阅读0次

    以nacos的namespace为例

    server:
      port: 9002
    
    spring:
      profiles:
        active: ken
      application:
        name: nacos-api-server
      cloud:
        config:
          namespaces:
            pro: xxxxxx
            ken: xxxxxx
          namespace: ${spring.cloud.config.namespaces.${spring.profiles.active}}
        sentinel:
          transport:
            dashboard: http://127.0.0.1:8080
            #默认为8719端口,如被占用则会+1扫描,直至找到未被占用的端口
            port: 8719
        nacos:
          discovery:
            server-addr: http://www.kenchen.icu:8848/ #配置Nacos地址
            namespace: ${spring.cloud.config.namespace}
            group: MOYO_GROUP
          config:
            server-addr: http://www.kenchen.icu:8848/ #配置Nacos地址
            namespace: ${spring.cloud.config.namespace}
            file-extension: yml        #指定yaml格式的配置
            group: MOYO_GROUP
    

    相关文章

      网友评论

          本文标题:springboot配置及多环境切换

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