开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜