xml创建对象,参数为properties配置

来源:互联网 发布:linux core dump 开启 编辑:程序博客网 时间:2024/06/18 04:45


正常创建properties参数的对象:

push.properties文件

#注册测试
host=sfsdfsdfappKey=8ODhr2Q5ORAwmasterSecret=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=sfsdfsdfappKey=8ODhr2Q5ORAwmasterSecret=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;