将@value放在set方法上
@Value("#{settings.xxx}") public void setName(String name) { this.name = name; }
spring的配置文件中(applicationContext.xml)添加util:
<beans xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd"> </beans> <util:properties id="settings" location="classpath:yyy.properties"></util:properties>
在yyy.properties里写值:
xxx=varxxx