当我试图在eclipse中运行spring程序时,我得到以下错误。
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
BeanFactory cannot be resolved to a type
XmlBeanFactory cannot be resolved to a type
FileSystemResource cannot be resolved to a type
triangle cannot be resolved
at Org.koushik.javabrains.DrawingApp.main(DrawingApp.java:8)
我试图解决此错误。我也下载spring.jar文件并把它放在classpath.But,我仍然得到错误。我也想要整个spring.jar应该包括 所有spring.jar文件。
请帮助我,并提前致谢。
答案 0 :(得分:1)
要管理您的依赖项,请使用Maven,Gradle或Ant + Ivy等工具。这些将使您的生活变得更加轻松,依赖关系将得到管理,您将获得所有传递依赖项(您使用的框架所依赖的依赖项)。这将为您节省大量的互联网搜索。
使用这些工具中的任何一个,您都可以创建一个构建文件(ant和maven使用XML,Gralde使用Groovy)并表达您的依赖关系。
例如,这个用于gradle的构建文件,build.gradle
将创建一个jar并使用所有依赖项。
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.springframework', name: 'spring-context', version: '3.2.5.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version: '3.2.5.RELEASE'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
这个gradle.build
将添加所需的spring jar及其所需的依赖项。
答案 1 :(得分:0)