我通过听“Spring & Hibernate for Beginners”udemy 课程来学习 Java Spring 框架。我在尝试导入org.springframework.context.support.ClassPathXmlApplicationContext时遇到了困难;
Eclipse 显示错误: ClassPathXmlApplicationContext 无法解析
我正在听的课程的作者仍然没有涉及 Maven(和 pom.xml),因为他在课程中专注于“纯”Java 和 Spring,所以请不要指导我使用 Maven 来组织项目。
我将spring-framework-5.0.2.RELEASE-dist中的所有 jar 添加到我的项目构建路径中。
有趣的是,当我执行 CTRL+Shift+O Eclipse 时,它会自动导入org.springframework.context.support.ClassPathXmlApplicationContext包,但它在导入行( org下的红线)中显示错误,并在我的 main 函数中显示错误我尝试使用上下文的行:
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
Run Code Online (Sandbox Code Playgroud)
请帮忙。