The thing is, as I understand it, <util: propertes id = "id" location = "loc" /> is just a shorthand for
<bean id="id" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="location" value="loc"/> </bean>
(see utility documentation: properties ). Thus, using the util: properties creates a standalone bean.
@PropertySource, on the other hand, as the documentation says,
An annotation providing a convenient and declarative mechanism for adding a PropertySource property in Spring Environment '.
(see @PropertySource doc ). Therefore, he does not create any bean.
Then "# {a ['something']}" is a SpEL expression (see SpEL ), which means "get something from bean 'a'". When used: properties are used, a bean exists, and the expression makes sense, but when @PropertySource is used, there is no actual bean, and the expression is meaningless.
You can get around this either with XML (which is best, I think), or by creating a PropertiesFactoryBean property, declaring it as a regular @ Bean.
Artem Shitov May 31 '13 at 9:40 a.m. 2013-05-31 09:40
source share