过程就不细写了,大致就是改动路径的配置重启获取配置之类的操作
先说怎么配置多个路径,其实比较简单
spring:
application:
name: config-server
profiles:
active: native
cloud:
config:
server:
native:
searchLocations: file:./,file:./config/,classpath:/config/
spring.profiles.active这里要指定用native为本地路径
spring.cloud.config.server.native.searchLocations 路径配置这里可以写多个路径 中间用逗号隔开就行yml的配置方法
然后就是读取顺序,是从前面往后面读取,这个应该没什么疑问,然后是后门读取的配置会覆盖前面读取的配置
也就是说写在后面的优先级更高
附带:
file:./ 是读取jar包所在的目录
file:./config 是读取jar包所在目录的config文件夹
classpath:/config 是读取类路径下config文件夹
classpath:/ 是读取类路径目录