2013-11-24 20 views
0

虽然我想在eclipse中运行spring程序,但我得到以下错误。为什么我无法运行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中。但是,我仍然收到错误信息。我还想要整个spring.jar文件,其中应该包含所有spring.jar文件的 。

请帮助我,并提前致谢。

+4

当使用较新版本的Spring(> 2.5)时,不再有spring.jar。我也强烈建议使用像Maven或Gradle这样的东西来管理你的依赖关系,而不是试图找出你需要的jar。 –

+0

@ M.Deinum可以为Maven或Gradle提供链接吗?为什么对Spring> 2.5应该使用Maven或Gradle。 – user1334247

+0

这不是说Gradle或Maven应该用于2.5以上的春天,它会减少你的工作量。你只需指定你需要的Spring模块,Maven就会为你下载所有的jar文件(依赖管理)。如果你手工操作,你需要下载Spring Jars以及其他一些罐子,这些罐子可能取决于哪一个,这在大多数时候都变得非常麻烦。 – M4ver1k

回答

0

您正在收到该异常,因为您没有正确的jar文件。

您需要这些罐子用于基于Spring IOC/DI模块的项目。 您可以从here

下载的罐子了解并开始使用像Deinum依赖管理工具说

enter image description here

1

要管理你的依赖等工具MavenGradleAnt + 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将添加所需的春天罐子和它需要的依赖关系。

+0

我尝试从Eclipse Market Place添加依赖项。但是,我无法找到哪个Maven需要安装。我怎么能找到哪个Maven适合? – user1334247

相关问题