我正在准备春季课程的介绍,但是我的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


我自己的路:

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

主要方法代码:

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

最佳答案

请不要忘记添加文件扩展名“ .xml”,spring将从src / main / resource中读取它

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


}

10-05 18:23