jcg*_*cia 3 java spring spring-boot
我正在尝试使用spring.config.name和spring.config.location属性自定义Spring Boot配置位置和配置名称,就像我在Spring Boot参考指南中看到的那样
我已经创建了一个Spring Boot基本应用程序来测试它.
我可以使用OS环境变量export SPRING_CONFIG_NAME=custom和/或来自定义它export SPRING_CONFIG_LOCATION=classpath:/custom/location.properties.这很好用!
但我想知道,如果可以spring.config.name=custom在默认情况下定义application.properties,然后创建一个custom.properties文件,我将能够定义所有应用程序配置属性.
我已经检查了它,似乎它不能定义
spring.config.name属性application.properties...但我想知道这是否是一个有效的方法来做到这一点之前在gitHub上创建一个问题.
问候,
从春季文档:
spring.config.location 环境属性(以逗号分隔的目录位置列表或文件路径)
此外,ConfigFileApplicationListener中的代码显示如果没有环境属性,则处理回退到:
DEFAULT_SEARCH_LOCATIONS = "classpath:/,classpath:/config/,file:./,file:./config/";
Run Code Online (Sandbox Code Playgroud)
并为名称:
DEFAULT_NAMES = "application";
Run Code Online (Sandbox Code Playgroud)
所以你正在做的事情不起作用是正常的.
| 归档时间: |
|
| 查看次数: |
7484 次 |
| 最近记录: |