Spring 使用@PropertySource读取properties文件
来源:互联网 发布:windows 查询端口 编辑:程序博客网 时间:2024/05/25 01:35
spring 3.1中开始引入 了读取properties文件的注解 @PropertySource
比如有customize.properties文件
#超级管理员的用户名userName=administrator#超级管理员用户密码password=admin123实现代码
@Configuration@PropertySource(value = "file:${user.dir}/config/customize.properties", ignoreResourceNotFound = true)public class InitCustomizeUrlConfig {}获取配置文件中的值通过Environment 具体使用方法
@Autowiredprivate Environment env;env.getProperty("userName")
在spring 3.2中,允许支持多个properties,
@Configuration @PropertySource({ "classpath:config.properties", "classpath:db.properties" //如果是相同的key,则最后一个起作用 }) public class AppConfig { @Autowired public Environment env; }
0 0
- Spring 使用@PropertySource读取properties文件
- Spring 使用@PropertySource+Emvironment读取properties文件
- Spring 从文件系统读取配置文件, 使用@PropertySource
- 使用spring读取properties文件
- Spring使用程序方式读取properties文件
- Spring使用程序方式读取properties文件
- spring使用注解@Value读取.properties文件
- 使用Spring PropertiesLoaderUtils读取properties属性文件
- Spring 读取 properties文件
- Spring 读取properties文件
- spring读取properties文件
- spring 读取properties文件
- spring读取properties文件
- spring读取properties文件
- Spring 读取properties文件
- spring 读取properties属性文件
- spring读取properties文件信息
- spring文件读取properties文件属性
- Xamarin Forms 进度条控件
- Keil-MDK查看代码量,RAM时候用情况Code;RO-data;RW-data;ZI-data的分析
- PHP装饰者模式
- iOS OC语言: Block底层实现原理
- Android 广播大全 Intent Action 事件
- Spring 使用@PropertySource读取properties文件
- rails server在windows下启动失败,提示已经启动问题处理。
- testng.xml顺序执行case
- pl/sql编程
- C++内联函数
- 黑幕背后的__block修饰符
- Android为什么要设计出Bundle而不是直接使用HashMap来进行数据传递 Android内存优化(使用SparseArray和ArrayMap代替HashMap)
- WEBService
- Android 强制停止RecyclerView滑动方法