在你的
Config类中添加以下bean声明
@Beanpublic static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer();}为了使
@Value注释生效,
PropertySourcesPlaceholderConfigurer应该注册。它使用时自动完成
<context:property-placeholder>的XML,但应注册为一个
static @Bean使用时
@Configuration。



