【发布时间】:2018-09-09 06:07:43
【问题描述】:
我最近开始学习spring框架。我将所有 spring 库添加到我的项目的类路径中。但是我收到了一个 import org not found 错误。
package com.springlearnging.springdemo;
//Getting error at this import
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class HelloSpringApp {
public static void main(String[] args) {
//load spring config file
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//retrieve bean from spring container
//call methods
//close context
}
}
【问题讨论】:
-
你能显示你的依赖关系吗?
-
你的类路径中有
spring-contextjar吗? -
我已经添加了春季版本 5.0.8 中的所有 jar。从这个网址。 repo.spring.io/release/org/springframework/spring
-
使用 maven 和 spring 将极大地帮助您正确快速地构建您的项目,一些 maven 功能link