【发布时间】:2012-05-28 05:11:35
【问题描述】:
我是 Spring 新手,并使用 Eclipse 从here 学习 Spring 教程。
但是,在 Eclipse 中我无法导入这两个库
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
我什至从 Spring 站点下载了 Spring 源文件,将其包含在系统库中,将其添加到我的项目中以及我的项目的 lib 文件夹中,但没有白费。
你能帮我知道问题出在哪里吗,请给我推荐一些好的 Spring 教程网站。
谢谢大家
编辑
这里是例外
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
ApplicationContext cannot be resolved to a type
ClassPathApplicationContext cannot be resolved to a type
at com.test.App.main(App.java:12)
【问题讨论】:
-
您是否包含了 jar 以及来源?这才是真正重要的。
-
不能在eclipse中导入他们的类不是spring的问题。在您的项目中包含这些 jar,然后重新启动 eclipse。我建议阅读 Spring in Action 3.0。手动导入这两个类时是否遇到任何编译错误?
-
@PaulBellora 是的,我确实包含了 jars 文件,甚至重新启动但无济于事
-
@VarunAchar 是的,我确实遇到了编译错误
-
@sameer,前段时间我也遇到过类似的问题。我认为不值得费心摆弄这一切,并安装了 SpringSource 工具套件。