<!-- if you are using annotations -->
<context:annotation-config/>
<!-- if you are scanning for annotated beans -->
<context:component-scan base-package="com.example.package" />
<!-- Load override configuration from a property file. -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="ignoreResourceNotFound" value="true"/>
<property name="locations">
<list>
<value>classpath:abc.properties</value>
<value>file:/etc/someplace/abc.properties</value>
</list>
</property>
</bean>
1条答案
按热度按时间vm0i2vca1#
看起来您正在尝试使用spring框架中的@value注解。
实际上,我认为你做得对。有没有可能你没有一个PropertyPlaceHolderConfigure?
大多数情况下,我都是通过向spring applicationcontext.xml配置文件中添加这样的内容来完成的: