这就是我设置外部配置文件的方式:
/** for .yaml file
@Configuration
@PropertySource("classpath:waterlvl.yaml")
@ConfigurationProperties("Alerts")
public class WaterLvlAlertConfig {
/** for .properties file
@Component
@PropertySource("classpath:waterlvl.properties")
public class WaterLvlConfig {
未选取属性,并且我的文件位于资源文件内。我认为我提供的路径是错误的。我做错了什么?
最佳答案
在 spring boot 中,使用 .yaml 配置时不能使用 @PropertySource。请参阅第 24.6.4 点外部化配置文档中的 YAML 缺点。另外,之前回答了类似的问题,请参阅-Spring boot external configuration of property file
关于java - Spring Boot 中的外部 YAML 属性文件和普通属性文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45754308/