[英]External YAML property file and normal properties file in Spring Boot
This is how I have set up external configuration file: 这是我设置外部配置文件的方式:
/** for .yaml file
@Configuration
@PropertySource("classpath:waterlvl.yaml")
@ConfigurationProperties("Alerts")
public class WaterLvlAlertConfig {
/** for .properties file
@Component
@PropertySource("classpath:waterlvl.properties")
public class WaterLvlConfig {
Properties are not being picked up, and my files are inside the resources file. 属性没有被提取,我的文件位于资源文件中。 I think the path I'm providing is wrong.
我认为我提供的路径是错误的。 What am I doing wrong?
我究竟做错了什么?
In spring boot @PropertySource cannot be used when using .yaml configuration. 在春季启动中,使用.yaml配置时无法使用@PropertySource。 Refer to point 24.6.4 YAML shortcomings in externalized configuration documents.
请参阅外部化配置文档中的点24.6.4 YAML缺点。 Also, a similar question is answered earlier, refer - Spring boot external configuration of property file
另外,前面已经回答了类似的问题,请参考-Spring Boot属性文件的外部配置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.