第一种:
config.properties:
index.version=v1
spring配置文件,加载config.properties:
<!-- 获取properties中的值 -->
<bean id="configProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:config.properties</value>
</list>
</property>
</bean>
<!-- Spring的动态变量,能在bean中直接调用 -->
<bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties" ref="configProperties" />
</bean>
注入使用:
@Value("#{configProperties['index.version']}")
public String ve