bootstarp文件的书写

本地配置

#微服务配置
spring:
  application:
    name: content-api # 服务名
  cloud:
    nacos:
      server-addr: 192.168.101.65:8848 # nacos 服务器地址,这个一定放在discovery上面,idea提示是错的
      discovery: # 让nacos发现这个服务才配置
        namespace: dev402 # 命名空间,在naocs里的
        group: xuecheng-plus-project # nacos中的属性
      config: # 需要从nacos拉取配置才写
        namespace: dev402
        group: xuecheng-plus-project
        file-extension: yaml
        refresh-enabled: true
        extension-configs: #拓展配置文件,从其他的配置文件直接继承过来
          - data-id: content-service-${spring.profiles.active}.yaml
            group: xuecheng-plus-project
            refresh: true
        shared-configs: # 共享配置文件
          - data-id: swagger-${spring.profiles.active}.yaml
            group: xuecheng-plus-common
            refresh: true
          - data-id: logging-${spring.profiles.active}.yaml
            group: xuecheng-plus-common
            refresh: true
  profiles:
    active: dev # 重要的,同时dev也是默认值,服务名-active.yaml 是这个文件请求的配置文件

nacos文件配置

文件名:content-service-dev.yaml

  spring:
    datasource:
      driver-class-name: com.mysql.cj.jdbc.Driver
      url: jdbc:mysql://192.168.101.65:3306/xc402_content?serverTimezone=UTC&userUnicode=true&useSSL=false
      username: root
      password: mysql

文件名:content-api-dev.yaml

server:
  servlet:
    context-path: /content
  port: 63040
#配置本地优先
spring:
  cloud:
    config:
      override-none: true
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值