xml创建对象,参数为properties配置
2017-12-13 17:37
239 查看
正常创建properties参数的对象:
push.properties文件
Java类:
当用xml文件创建对象时:
push.properties文件
XML文件
Java类:
@Resource(name = "pushMessage")
private IGtPush push;
push.properties文件
#注册测试
host=sfsdfsdf appKey=8ODhr2Q5ORAw masterSecret=XL8wnCHHKlAun
Java类:
@PropertySource(value="classpath:META-INF/push.properties") // Android系统 @Value("${host}") private String host; @Value("${appKey}") private String appKey; @Value("${masterSecret}") private String masterSecret; IGtPush push = new IGtPush(host, appKey, masterSecret);
当用xml文件创建对象时:
push.properties文件
#注册测试
host=sfsdfsdf appKey=8ODhr2Q5ORAw masterSecret=XL8wnCHHKlAun
XML文件
<bean id="pushMessage" class="com.gexin.rp.sdk.http.IGtPush"> <constructor-arg index="0" value="${host}" /> <constructor-arg index="1" value="${appKey}" /> <constructor-arg index="2" value="${masterSecret}" /> </bean>
Java类:
@Resource(name = "pushMessage")
private IGtPush push;
相关文章推荐
- Spring4.3.x 浅析xml配置的解析过程(2)——使用ResourceLoader创建Resource对象
- Spring框架xml配置文件 复杂类型属性注入——数组 list map properties DI dependency injection 依赖注入——属性值的注入依赖于建立的对象(堆空间)
- 编写一个文件,读取 src 下面day12包 下面的my.properties 文件,文件内容如下, className=day12.User 结合 IO、反射知识,完成 配置文件中对象的创建和方法调用。并编写方法,列举出 Student 类中所有的属性、
- 在Spring的配置文件applicationContext-mybatis.xml中配置数据源对象中,配置SQL心跳包及参数含义
- xml读取properties配置文件,web.xml读取properties,properties格式,properties在eclipse创建
- Spring_使用XML配置文件创建对象
- xml读取properties配置文件,web.xml读取properties,properties格式,properties在eclipse创建
- 经过修改的读取配置文件PROPERTIES的小工具,对象尽量创建一次
- 02 Mybatis应用篇---XML配置之properties 属性和settings 设置
- Spring mail 邮件服务及其参数配置(properties文件的读写)
- Java_Web Project_web.xml参数配置、servlet配置;
- 创建跨浏览器访问的 XMLHttpRequest 对象
- JavaEE自定义标签:标签类的创建、tld配置文件的创建(位置、如何创建)、Web-XML配置、JSP应用
- 修改Struts2的struts.xml配置文件位置和名称-重点是init-param参数用来切换加载的路径
- 对datatable对象参数进行部分配置以及说明
- 创建一个日期对象, 日期对象可传参数
- zTree组织机构树(涉及技术包含:zTree参数配置,ajax框架,jquery惊细控制对象,用户自定义控件,webmethod)
- Servlet 读取web.xml文件中的配置参数连接数据库
- java开发中常用的xml,properties配置
- yarn-site.xml相关配置参数