How to use the @Value annotation with a Spring PropertyPlaceholderConfigurer in a Spock test?
It is possible to use the @Value annotation with a Spring PropertyPlaceholder开发者_如何学编程Configurer?
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:location="classpath:application-test.properties" />
The <util:properties id="appProperties" location="classpath:application-test.properties" />
works correct with @Value but i would like to use 1 way of configuring. Now i have the both of them pointing towards the same property file.
You do not need to use a PropertyPlaceholderConfigurer if you have already setup util:properties. In your bean config, create the util:properties bean and then within your classes annotate like
@Value("#{myProps.someProperty}")
http://forum.springsource.org/showthread.php?69602-Value-and-PropertyPlaceholderConfigurer
精彩评论