赞
踩
两种方法其实都是一样的
在类中读取properties文件属性
在类中需要注入的属性实现 setter 和 getter 方法。
在 setter 方法前,添加 @Value 注解
@Value("#{propertiesReader[propertiesName]}")
propertiesName 为 properties 文件中的键。这样,在容器启动过程中, Spring 将自动注入值。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。