标签:
1.方式一
<util:properties id="meta" location="classpath:config/metainfo.properties" />
@Value("#{meta[‘pubVersion‘]}")
private String pubVersion
2方式二:
<bean id="configPropertiesTest" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>file:${global.config.path}/opc/opc-business/jdbc.write.properties</value>
<value>file:${global.config.path}/opc/opc-business/jdbc.read.properties</value>
</list>
</property>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
<property name="properties" ref="configPropertiesTest" />
</bean>
@Value("#{configPropertiesTest[‘jdbc.read.username‘]}")
private String testKey;
启动时加入参数 -Dglobal.config.path=E:\opc_workspace\opc\conf
标签:
原文地址:http://www.cnblogs.com/liuzy2014/p/5001487.html