一 点睛
当微服务数量很庞大时,将所有配置都书写到一个配置文件中,显然不是太合适。对此我们可以将配置按照功能的不同,拆分为不同的配置文件。
二 操作步骤
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