spring 使用注解获取properties 文件属性值
来源:互联网 发布:单片机智能车 编辑:程序博客网 时间:2024/05/22 10:31
1.配置bean 截取片段
<!-- 引入配置文件 --><bean id="configProperties"class="org.springframework.beans.factory.config.PropertiesFactoryBean"><property name="locations"><list><value>classpath:application.properties</value></list></property></bean><bean id="propertyConfigurer"class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer"><property name="properties" ref="configProperties" /></bean>
2.properties 的配置
#资讯网站配置web.catch.url=first.name=hering
3.java 代码中获取属性值的配置 不需要使用set get 方法,好像还有一种使用get set 方式的。待我研究一下怎么使用,再写出来。
@Value("#{configProperties['first.name']}")private String myname;
4.测试结果
@RequestMapping("getinfo")@ResponseBodypublic WebJson getInfo(@RequestParam (value="id",required=true)Integer id){WebJson json=new WebJson();System.err.println(myname+"-------");//Assert.notNull(info,"【getInfo】系统无法查询到id="+id+"的资讯");return json;}
Hibernate: select infomation0_.id as id1_0_, infomation0_.author as author2_0_, infomation0_.content as content3_0_, infomation0_.created as created4_0_, infomation0_.source as source5_0_, infomation0_.summary as summary6_0_, infomation0_.title as title7_0_ from infomation infomation0_ where infomation0_.id=?
hering-------
0 0
- spring 使用注解获取properties 文件属性值
- 关于spring使用@value注解获取properties文件属性问题
- 通过Spring获取properties文件属性值
- Spring EmbeddedValueResolverAware 接口获取properties文件属性
- Spring取得*.properties文件属性
- @Value spring 注解 获取*.properties 的属性值
- Spring通过注解@Value获取properties配置
- spring文件读取properties文件属性
- (转) spring配置文件(xml)读取properties文件属性值
- 使用java读写properties文件属性
- spring注解中使用properties文件
- spring使用注解@Value读取.properties文件
- Spring之@Value 注解获取properties值(Spring 3的@value简化配置文件的读取)
- spring项目properties文件属性配置到数据库
- spring配置文件获取其他properties文件中的值及使用
- spring基于注解的方式获取.properties文件中的数据
- spring注解注入properties属性值
- 使用spring注解方法读取properties文件中值
- Qt学习笔记01
- c语言实现一个简单的语法分析器
- 1、CommonUtils.uuid()和CommonUtils.toBean(map, Person.class)
- 项目起不来解决方案
- 项目-两个成员的类模板将类声明改为类模板声明,使得数据成员data1和data2可以是任何类型
- spring 使用注解获取properties 文件属性值
- 求特征值
- static linked list(静态链表,结合数组实现)
- 项目-数组类模板在数组类的基础上,将之改造为类模板,以使数组中可以存储各种类型的数据
- 项目-两个成员的类模板为该类增默认构造函数、带两个参数分别对应两个数据成员初值的构造函数,以及复制构造函数
- Node.js与io.js那些事儿
- Android Framework解析
- 强化学习基本方法(一)
- oc 中代码块中局部变量与全局变量、全局静态变量