(Spring)java.io.FileNotFoundException问题:无法打开类路径资源,因为它不存在
我想从类路径资源中获取属性文件app.properties。 原因是我正在使用maven构建一个jar文件。jar文件正在从jar内部获取属性。因此,其他人无法更改属性文件 我希望属性文件是可配置的(Spring)java.io.FileNotFoundException问题:无法打开类路径资源,因为它不存在,java,spring,Java,Spring,我想从类路径资源中获取属性文件app.properties。 原因是我正在使用maven构建一个jar文件。jar文件正在从jar内部获取属性。因此,其他人无法更改属性文件 我希望属性文件是可配置的 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"&
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>app.properties</value>
</list>
</property>
</bean>
app.properties
很好,但是
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>"C:\\Temp\\app.properties"</value>
</list>
</property>
</bean>
“C:\\Temp\\app.properties”
不起作用
是否可以将属性文件放在目标文件夹中,以便jar可以从jar外部拾取它?尝试
<property name="location"><value>file:C:/Temp/app.properties</value></property>
文件:C:/Temp/app.properties
尝试使用
<property name="location"><value>file:C:/Temp/app.properties</value></property>
文件:C:/Temp/app.properties
我不确定,但指定路径名时是否需要双反斜杠?C:\\Temp\\app……是的,我也试过了。相同的问题我不确定,但指定路径名时是否需要双反斜杠?C:\\Temp\\app……是的,我也试过了。同样的问题我只是在无意中编辑了这个。最好拒绝它我只是在无意中编辑了这个。最好拒绝它