问题描述
当我尝试在Eclipse中运行spring程序时,出现以下错误.
While i am trying to run spring program in eclipse i get following error.
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文件并将其放在类路径中.但是,仍然出现错误.我还希望整个spring.jar其中应包括所有spring.jar文件.
I tried to resolve this error. I also download spring.jar file and put it in the classpath.But, still i am getting error.I also want whole spring.jar which should includeall spring.jar file.
请帮助我,谢谢.
推荐答案
要使用诸如 Maven 之类的工具来管理依赖项, Gradle 或蚂蚁+常春藤.这些将使您的生活变得更加轻松,将管理依赖项,并且您还将获得所有传递性依赖项(您使用的框架所依赖的依赖项).这将节省您在互联网上进行大量搜索的时间.
To manage your dependencies use tools like Maven, Gradle or Ant + Ivy. Those will make your life a whole lot easier, the dependencies will be managed and you will get also all transitive dependencies (the dependencies the framework you use depends on). This will save you a lot of searching around the internet.
使用这两种工具之一,您都可以创建一个构建文件(ant和maven使用XML,Gralde为此使用Groovy)并表达您的依赖关系.
With either of these tools you create a build file (ant and maven use XML, Gralde uses Groovy for that) and express your dependencies.
例如,用于gradle的此构建文件 build.gradle
将创建一个jar并使用所有依赖项.
For example this build file for gradle, build.gradle
will create a jar and use all the dependencies.
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和其所需的依赖项.
This gradle.build
will add the needed spring jars and the dependencies it needs for that.
这篇关于为什么我不能运行Spring程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!