![](/img/trans.png)
[英]Springboot @PropertySource with --spring.config.location=/etc/foo/
[英]What to set for Spring's @PropertySource when using spring.config.location command line arg?
我已经定义了一个@Config
类,如下所示:
@Config
@PropertySource(value = "")
public class Foo {
...
}
我通过运行以下程序来运行程序:
--spring.config.location=file:///Users/dev/workspace/application.yml
问题是我无法省略PropertySource批注的'value'属性。 为什么需要设置? 那会覆盖我在--spring.config.location
设置的--spring.config.location
吗? 我应该使用SimpleCommandLinePropertySource
而不是--spring.config.location
吗?
当您使用spring.config.location使用外部属性文件时,只需在配置类中设置值:
@Config
@PropertySource(value = "${spring.config.location}")
public class Foo {
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.