/**
* @ClassName: PropertiesConfig
* @Description: 读取配置文件
* @author lml
* @date 2019年10月23日 下午5:35:21
*
*/
@Configuration
public class PropertiesConfig {
@Bean
public PropertySourcesPlaceholderConfigurer createPropertySourcesPlaceholderConfigurer() {
ClassPathResource resource = new ClassPathResource("pay-dev.properties");
PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
propertyPlaceholderConfigurer.setLocation(resource);
return propertyPlaceholderConfigurer;
}
}
spring项目自定义配置文件
最新推荐文章于 2024-06-13 21:13:53 发布
本文介绍了一个使用Spring框架读取配置文件的方法,通过创建一个名为PropertiesConfig的类,并定义了一个Bean来加载并配置属性占位符,使应用程序能够从类路径下的pay-dev.properties文件中读取属性。
2万+

被折叠的 条评论
为什么被折叠?



