Nacos加载多个配置集

一 点睛

当微服务数量很庞大时,将所有配置都书写到一个配置文件中,显然不是太合适。对此我们可以将配置按照功能的不同,拆分为不同的配置文件。

二 操作步骤

1 原来的配置文件

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.0.110:3306/gulimall_sms
    driver-class-name: com.mysql.jdbc.Driver
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848
  application:
    name: gulimall-coupon

mybatis-plus:
  mapper-locations: classpath:/mapper/**/*.xml
  global-config:
    db-config:
      id-type: auto
server:
  port: 7000

2 将该配置文件拆分成3个配置文件

a datasource.yml:用于存储和数据源有关的配置

spring:
  datasource:
    username: root
    password: root
    url: jdbc:mysql://192.168.0.110:3306/gulimall_sms
    driver-class-name: com.mysql.jdbc.Driver

b mybatis.yml:用于存储和mybatis相关的配置

mybatis-plus:
  mapper-locations: classpath:/mapper/**/*.xml
  global-config:
    db-config:
      id-type: a
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值