我正在尝试将下一个注释应用于配置类:
@Configuration
@EnableCaching
@ComponentScan({ "com.foo.*" })
@PropertySources({
@PropertySource("classpath:foo.properties"),
@PropertySource(value = "file:${catalina.home}/conf/foo.properties", ignoreResourceNotFound = true),
})
但我遇到以下异常:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.company.config.CoreConfig]; nested exception is java.io.FileNotFoundException: class path resource [foo.properties] cannot be opened because it does not exist
我尝试在 Google 上查找此错误,并发现了许多相关内容,但没有任何内容可以帮助我。
文件路径为:
/home/me/apache-tomcat-8.0.36/conf
最佳答案
我通过删除这一行解决了这个问题:
@PropertySource("classpath:foo.properties"),
关于java - 无法从@PropertySource读取配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44435605/