我對春天的上下文有非常奇怪的問題。上下文不存在
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