Eclipse Spring中正确的文件路径是什么

时间:2018-12-12 23:20:38

标签: java spring eclipse spring-boot filenotfoundexception

我正在准备春季课程的介绍,但是我的SpringConfig.xml文件路径有问题。如图所示,我只是将它添加到任何地方以致哀悼,但这也不起作用:

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [SpringConfig]; nested exception is java.io.FileNotFoundException: class path resource [SpringConfig] cannot be opened because it does not exist

我的路径:

enter image description here

主要方法代码:

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("SpringConfig");
}

1 个答案:

答案 0 :(得分:0)

请不要忘记添加文件扩展名“。xml” ,spring将从 src / main / resource

中读取它
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("SpringConfig.xml");


}
相关问题