spring boot指定外部配置的坑

外部配置文件所在目录path/to/dir

指定--spring.config.location=path/to/dir

项目启动,没有使用任何配置文件,项目外和jar包中的都没有使用

这是因为其把path/to/dir当成一个文件读取,没有读取到任何内容

指定--spring.config.location=path/to/dir/application-{profile}.yml 可以

指定--spring.config.location=path/to/dir/ 也可以,这是会按优先级顺序,读取目录下所有配置文件

原文地址:https://www.cnblogs.com/mhc-fly/p/10979181.html