Using spring3 @Value to access PropertyPlaceholderConfigurer values?

后端 未结 3 1330
猫巷女王i
猫巷女王i 2021-01-17 13:37

I\'m trying to set the value of a string in a spring bean using @Value, when my property source is a subclass of PropertyPlaceholderConfigurer. Any

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-17 14:16

    Old question, but still worth to be answered. You can use the expression the same way as you would with the original PropertyPlaceholderConfigurer.

    app.properties

        app.value=Injected
    

    app-context.xml

        
          
            file:app.properties
          
        
    

    in the target bean

        @Value(value="${app.value}")
        private String injected;
    

    Tested this approach using Spring 3.0.6

提交回复
热议问题