自定义配置加载
利用@PropertySource注解既可以引入配置文件,需要引入多个时,可使用@PropertySources设置数组,引入多个文件。
/**
*单个文件
*/
@PropertySource(value = "classpath:myDefine.properties",encoding = "utf-8")
/**
* 多个配置文件
*/
1)方法一,设置数组
@PropertySource(value = { "classpath:myDefine.properties","classpath:myConfig.properties"},encoding = "utf-8")
2)方法二,spring4新增注解PropertySources
@PropertySources({
@PropertySource(value = "classpath:myDefine.properties",encoding = "utf-8"),
@PropertySource(value = "classpath:myConfig.properties",encoding = "utf-8")
})