我正在准备春季课程的介绍,但是我的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
我自己的路:
主要方法代码:
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");
}