demo-parent:
--web
--src
--main
--java
--Application.java
--resources
--application.yml
--application-mysql.yml
--service
--common
--src
--main
--java
--Config.java
--resources
--core-application.yml
有一些喜歡spring properties。如何在我的網路模塊中獲取它們?core-applicationspring.kafka.properties.bootstrap.servers
我現在有一個錯誤FileNotFoundException: class path resource [core-application.yml] cannot be opened because it does not exist。
uj5u.com熱心網友回復:
根據@PropertySourceJava 8 約定,注釋是可重復的。因此,如果我們使用 Java 8 或更高版本,我們可以使用這個注解來定義多個屬性位置:
@PropertySource("classpath:foo.properties")
@PropertySource("classpath:bar.properties")
public class PropertiesWithJavaConfig {
//...
}
@PropertySources({
@PropertySource("classpath:foo.properties"),
@PropertySource("classpath:bar.properties")
})
public class PropertiesWithJavaConfig {
//...
}
參考這篇文章,https://www.baeldung.com/properties-with-spring
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/510012.html
標籤:爪哇春天弹簧靴行家特性
上一篇:如何準確找出哪個pom依賴項?
