[英]Not able to find Spring “classpath:” location
I have a Spring Project where I am using bean configuration file beans.xml
.Inside the bean Configuration file, i have defined some properties for a PlaceHolder which refers to classPath...While the application is running, the properties are getting loaded from /unknownPath/Dev/Loc1/System.properties
我有一个Spring Project,正在使用bean配置文件
beans.xml
在bean配置文件中,我为PlaceHolder定义了一些属性,该属性引用了classPath ...在应用程序运行时,这些属性从/unknownPath/Dev/Loc1/System.properties
加载/unknownPath/Dev/Loc1/System.properties
Where 哪里
${BUS_ENV}=Dev
${LOCATION1}=Loc1
<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:${BUS_ENV}/${LOCATION1}/system.properties</value>
<value>classpath:${BUS_ENV}/lbsprocessor.properties</value>
</list>
</property>
<!-- Force system properties to override any deployed runtime properties -->
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name="ignoreUnresolvablePlaceholders" value="true" />
</bean>
Dev/Loc1/System.properties
Dev/Loc1/System.properties
If you are using eclipse IDE right click on your project select properties then select Java Build Path. 如果使用的是eclipse IDE,请在项目上单击鼠标右键,选择“属性”,然后选择“ Java构建路径”。 On first tab Source there is one input named Default Output folder that value is your classpath.
在第一个选项卡Source上,有一个名为Default Output文件夹的输入,该值是您的类路径。 Check all your properties files are there in that path.
检查所有属性文件是否在该路径中。
Referring to your point 2
problems might be in these line 提到您的
point 2
问题可能在这些行中
<value>classpath:${BUS_ENV}/${LOCATION1}/system.properties</value>
<value>classpath:${BUS_ENV}/lbsprocessor.properties</value>
You are using classpath
for file location which means these properties file have to be in the .war file at /Dev/Loc1/System.properties
您正在使用
classpath
作为文件位置,这意味着这些属性文件必须位于/Dev/Loc1/System.properties
的.war文件中
If properties files are outside of project may be at system level you can access them like this 如果属性文件不在项目中,则可能在系统级别,您可以像这样访问它们
<value>file:${BUS_ENV}/${LOCATION1}/system.properties</value>
<value>file:${BUS_ENV}/lbsprocessor.properties</value>
eg: 例如:
<value>file:/home/testuser/system.properties</value>
我使用的是Mac OS,因此我们将配置存储为jar文件,存储在/ Library / Java / Extension下。因此,默认情况下,java直接将类路径引用到该位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.