SpringMVC通过@Value注解读取.properties配置
2016-10-07 22:54
369 查看
SpringMVC通过@Value注解读取.properties配置
在bean(可以是controller、service、dao等)中,使用@Value注解:public class TestService{
@Value("${sytem.username}")
String loginUserName;
}
在spring中定义资源文件:
<!-- 导入属性配置文件 -->
<context:property-placeholder location="classpath:properties/*.properties" ignore-unresolvable="true" />
config.properties文件:
sytem.username=admin
这样config.properties中的sytem.username就注入到loginUserName属性中了。
原文链接:http://www.itdadao.com/articles/c15a352661p0.html
相关文章推荐
- SpringMVC通过@Value注解读取.properties配置
- springmvc通过@Value注解读取Properties配置文件的值,junit测试可以取到值,但是在业务中无法读取
- SpringMVC通过@Value注解读取.properties配置
- 通过@Value注解读取.properties配置内容 (续)
- 通过@Value注解读取.properties配置内容
- Spring MVC 通过@Value注解读取.properties配置内容
- Spring MVC 通过@Value注解读取.properties配置
- Spring MVC 通过@Value注解读取.properties配置
- Spring MVC 通过@Value注解读取.properties配置内容
- 通过@Value注解读取.properties配置内容
- Spring MVC 通过@Value注解读取.properties配置内容
- springMvc 如何通过注解@Value 读取配置文件中的内容(.properties)
- Spring MVC 通过@Value注解读取.properties配置内容
- Spring MVC 通过@Value注解读取.properties配置结果为null
- 通过@Value注解读取.properties配置内容
- 通过@Value注解读取.properties配置内容
- 通过@Value注解读取.properties配置内容
- Spring MVC 通过@Value注解读取.properties配置
- 通过@Value注解读取.properties配置内容
- 通过@Value注解读取.properties配置内容