一、bootstrap.properties最先加載,由spring applicationContex加載引導系統啓動配置,不會被application.propertis覆蓋java
二、springboot默認配置文件名application.propertes(yml)spring
三、添加新配置配置文件:spring.profiles.include=db,base 能夠自動包含一下兩個配置bootstrap
application-db.propertiesspringboot
application-base.propertiesapp
或者經過this
@PropertySource("application-db.properties") 也能夠實現一樣效果spa
四、值獲取code
4.一、@Value(${pool.core})get
4.二、能夠獲取系統下全部屬性值io
@Autowired
private Environment environment;
4.三、configurationProperties(prefix="db")
第二種方式 @Configuration @PropertySource("classpath:jdbc.properties") @ConfigurationProperties(prefix="db") publicclassDBProperties{ private String username; private String password; public String getUsername(){ return username; } public void setUsername(String username){ this.username=username; } public String getPassword(){ return password; } public void setPassword(String password){ this.password=password; } }