没有为org.springframework下载文件:org.springframework.core:3.2.2.RELEASE

时间:2016-08-13 16:47:41

标签: java spring maven intellij-idea

我使用intellij创建了一个小型java应用程序,后来我使用"添加框架支持"将该项目更新为Maven项目。选项。当我厌倦了在项目中添加spring jar文件时,我得到了以下错误,"没有为org.springframework下载文件:org.springframework.core:3.2.2.RELEASE"。

以下是我添加spring jar文件的步骤

1)点击文件 - >项目结构 - >模块 - >点击" +"标志 - >图书馆 - >来自Maven

2)搜索org.springframework.core并选择3.2.2 Release

3)下载到我项目下的lib文件夹。

4)出现错误。

我不知道哪里出错了。我是java和spring应用程序的新手。

2 个答案:

答案 0 :(得分:1)

如前所述,Maven自己下载依赖项(这是构建自动化工具的原因)。

要将Spring添加为依赖项,请将此代码添加到Maven的pom.xml中(该文件位于模块的根目录中):

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.2.2.RELEASE</version>
    </dependency>
</dependencies>

此外,从项目根目录中删除lib目录 - Maven不会将jar放在那里。

答案 1 :(得分:0)

Maven会自动下载依赖项,您可以尝试将其添加到pom.xml文件中。 Maven应该自动下载依赖项..

<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>3.2.2.RELEASE</version>
</dependency>