【发布时间】:2017-02-24 02:44:45
【问题描述】:
代码如下:
public class RootInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
protected Class<?>[] getRootConfigClasses() {
return new Class<?>[]{RootConfig.class};
}
protected Class<?>[] getServletConfigClasses() {
return new Class<?>[]{WebConfig.class};
}
protected String[] getServletMappings() {
return new String[]{"/"};
}
}
@Configuration
@ComponentScan(basePackages = "com.wasu.accounting.service")
@PropertySource(value = "classpath*:/test.properties")
public class RootConfig {
@Bean
public static PropertyPlaceholderConfigurer propertyPlaceholderConfigurer(){
return new PropertyPlaceholderConfigurer();
}
}
项目结构
当我启动 tomcat 时,出现以下错误:
类 org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanDefinitionStoreException:失败 解析配置类[com.test.accounting.config.RootConfig]; 嵌套异常是 java.io.FileNotFoundException: 无法打开 ServletContext 资源 [/classpath*:/test.properties]
【问题讨论】: