springboot配置及多环境切换

2024-04-22  本文已影响0人  KenChen_939

以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
上一篇下一篇

猜你喜欢

热点阅读