我有一个Spring引导应用程序,我不想注入属性。在我们以前的项目中,我们定义在我们context.xml
一个PropertyPlaceholderConfigurer
一次加载所有依赖模块的属性文件:Spring Java配置:PropertyPlaceholderConfigurer的“位置”等效
<bean id="propertyPlaceholderConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="true" />
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="locations">
<list>
<value>classpath:test.properties</value>
<value>classpath*:/META-INF/*.properties</value>
</list>
</property>
</bean>
现在我正在寻找在Java的配置风格值得选择。我想我的标注配置类,如下所示:
@PropertySources(value = { @PropertySource("classpath:application.properties"),
@PropertySource("classpath*:/META-INF/*.properties") })
但@PropertySource
注释不喜欢通配符(这是有道理的,因为它是负责提取单个资源)。
任何想法,提示,解决方案?
。请注意,声明'PropertyPlaceholderConfigurer'豆和'@ PropertySources'是不等价的。 – 2014-09-02 15:50:26
[classpath-wildcard-in-propertysource]可能重复(http://stackoverflow.com/questions/14389995/classpath-wildcard-in-propertysource)。 – tmarwen 2014-09-02 15:53:54
谢谢你们! – achingfingers 2014-09-02 15:55:23