我对弹簧上下文有一个非常奇怪的问题。
public static void main(String[] args) {
File file = new File("/home/user/IdeaProjects/Refactor/src/spring-cfg.xml");
System.out.println("Exist "+file.exists());
System.out.println("Path "+file.getAbsoluteFile());
ApplicationContext context = new ClassPathXmlApplicationContext(file.getAbsolutePath());
在控制台上显示:
Exist true
Path /home/user/IdeaProjects/Refactor/src/spring-cfg.xml
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [home/user/IdeaProjects/Refactor/src/spring-cfg.xml]; nested exception is java.io.FileNotFoundException: class path resource [home/user/IdeaProjects/Refactor/src/spring-cfg.xml] cannot be opened because it does not exist