@Value not resolved when using @PropertySource annotation. How to configure PropertySourcesPlaceholderConfigurer?

前端 未结 11 1198
情深已故
情深已故 2020-11-28 23:11

I have following configuration class:

@Configuration
@PropertySource(name = \"props\", value = \"classpath:/app-config.properties\")
@ComponentScan(\"service         


        
11条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 23:47

    Don't you need a method on your @Configuration class that returns PropertySourcesPlaceholderConfigurer, annotated @Bean and is static, to register any @PropertySource with Spring?

    http://www.baeldung.com/2012/02/06/properties-with-spring/#java

    https://jira.springsource.org/browse/SPR-8539

提交回复
热议问题