在你的上下文中配置PropertyPlaceholder:
<context:property-placeholder location="classpath*:my.properties"/>
然后,你引用bean中的属性:
@Componentclass MyClass { @Value("${my.property.name}") private String[] myValues;}编辑:更新了代码以使用逗号分隔的多个值来解析属性:
my.property.name=aaa,bbb,ccc
如果那不起作用,则可以定义一个带有属性的bean,手动注入和处理它:
<bean id="myProperties" > <property name="locations"> <list> <value>classpath*:my.properties</value> </list> </property></bean>
and the bean:
@Componentclass MyClass { @Resource(name="myProperties") private Properties myProperties; @PostConstruct public void init() { // do whatever you need with properties }}


