我正在使用PropertyPlaceholderConfigurer
从eclipse中的类路径访问属性文件<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath :database.properties</value>
</property>
</bean>
然而,在使用maven创建jar时,我排除了属性文件。
然后我将jar放在属性文件夹中的基本安装文件夹和属性文件中。
现在我使用
执行jarjava -cp ../properties/* abc.jar
它在初始化xml错误时无法找到database.properties文件。
答案 0 :(得分:0)
<context:property-placeholder location="/WEB-INF/classes/*.properties" />
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>${app.jdbc.username}</value>
<value>${app.jdbc.password}</value>
</property>
</bean>