无法从@PropertySource读取配置文件

时间:2017-06-08 12:18:54

标签: java spring ubuntu gradle annotations

我试图将下一个注释应用于配置类:

@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:失败   解析配置类[com.company.config.CoreConfig];   嵌套异常是java.io.FileNotFoundException:类路径资源   [foo.properties]无法打开,因为它不存在

我试图在谷歌上查找此错误并发现许多相关内容,但没有任何可以帮助我的内容。

文件路径为:

  

/home/me/apache-tomcat-8.0.36/conf

1 个答案:

答案 0 :(得分:1)

我通过删除这一行解决了这个问题:

@PropertySource("classpath:foo.properties"),
相关问题