使用Spring读取migration.properties时出现“ FileNotFoundException”。
<context:property-placeholder location="classpath:/config/migration.properties" />
文件目录:迁移-> src-> config
堆栈跟踪:
`Caused by: java.io.FileNotFoundException: class path resource [config/migration.properties] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158)
at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:143)
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:98)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:175)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:156)
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:142)
... 8 more`
Caused by: java.io.FileNotFoundException:
您的文件可能不在您认为的位置。我建议您打开文件夹,然后仔细检查文件的路径。我经常在Mac上单击“复制文件路径”以使其更容易使用。
您在此处描述的路径将是:Migration-> src-> config
/migration/src/config/migration.properties
如果文件名为migration.properties
另一个问题可能是/ Migration / src / config文件夹需要位于您的类路径中。(原来这就是问题所在)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句