【发布时间】:2016-11-11 03:18:59
【问题描述】:
我正在尝试使用 Spring 加载属性文件,该文件位于我的 WEB-INF 文件夹中。
我收到以下错误:
org.springframework.beans.factory.BeanDefinitionStoreException: 失败 解析配置类[com.elastictest.config.ProdConfig]; 嵌套异常是 java.io.FileNotFoundException: \WEB-INF\config\prod.properties(系统找不到路径 指定)
这是我的生产配置文件:
@Configuration
@Profile("prod")
@PropertySource("file:${prodPropertiesFile}")
public class ProdConfig {
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
这是我的 web.xml 声明:
<context-param>
<param-name>prodPropertiesFile</param-name>
<param-value>/WEB-INF/config/prod.properties</param-value>
</context-param>
我已经打开了战争并验证了属性文件在 WEB-INF/config 文件夹下。有什么想法吗?
【问题讨论】:
标签: java spring-mvc