我有两个Spring项目,后端和前端。后端的升级没有问题(Spring 4.1.2.RELEASE)。虽然部署前端我有这样的例外:切换到Java 1.8后,无法打开ServletContext资源[/jdbc.properties] - Spring 4
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [acn.spring.config.AppConfig]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/jdbc.properties]
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:489)
....
Caused by:
java.io.FileNotFoundException: Could not open ServletContext resource [/jdbc.properties]
这是WebAppInitializer的前端:
@Configuration
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class<?>[] { AppConfig.class };
}
.....
AppConfig的是后端项目,看起来像这样:
@Import(DataConfig.class)
@Configuration
public class AppConfig {
...
}
缺少的属性文件用于此处导入的DataConfig中:
@PropertySource("jdbc.properties")
@Configuration
public class DataConfig {
...
}
为什么找不到属性文件?
编辑:后端的罐结构:
- META-INF
- MANIFEST.MF
- 行家
- mySourcePackages结构
- jdbc.properties
前端的战争结构:
- META-INF
- MANIFEST.MF
- 行家
- 资源
- WEB-INF
- 类
- 个mySourcePackages结构
- JSP
- LIB
- 所有的罐子包括backend.jar
- 类
非常感谢! – akcasoy 2014-11-21 20:04:01