Maven没有下载依赖项的JAR包

3
我正在尝试在我的Windows机器上安装Maven。我尝试了3.2.3和3.1.1两个版本。我在我的eclipse中安装了m2eclipse插件。
我在我的pom.xml文件中添加了以下依赖项(仅作为示例):
<dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-tools</artifactId>
        <version>1.1.7.RELEASE</version>
    </dependency>
</dependencies>

Eclipse提示错误:缺少依赖组件 org.springframework.boot:spring-boot-tools:jar:1.1.7.RELEASE

在我的.m2仓库中,我有.pom文件、.jar.lastUpdated文件,但没有实际的.jar文件

当我执行mvn -X clean install命令时,会出现以下堆栈跟踪信息:

[ERROR] Failed to execute goal on project SpringTest_Boot: Could not resolve dependencies for project SpringTest_Boot:SpringTest_Boot:jar:0.0.1-SNAPSHOT: Failure to find org.springframework.boot:sprin
g-boot-tools:jar:1.1.7.RELEASE in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates
 are forced -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project SpringTest_Boot: Could not resolve dependencies for project SpringTest_Boot:SpringTest_Boot:jar:0.0.1-SNAPSHOT
: Failure to find org.springframework.boot:spring-boot-tools:jar:1.1.7.RELEASE in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the u
pdate interval of central has elapsed or updates are forced
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:220)
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:127)
        at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:257)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:200)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project SpringTest_Boot:SpringTest_Boot:jar:0.0.1-SNAPSHOT: Failure to find org.springframework.bo
ot:spring-boot-tools:jar:1.1.7.RELEASE in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or
 updates are forced
        at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:198)
        at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:195)
        ... 22 more
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Failure to find org.springframework.boot:spring-boot-tools:jar:1.1.7.RELEASE in http://repo.maven.apache.org/maven2 was cached i
n the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:384)
        at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:192)
        ... 23 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Failure to find org.springframework.boot:spring-boot-tools:jar:1.1.7.RELEASE in http://repo.maven.apache.org/maven2 was cached in
the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:459)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:262)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
        ... 24 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Failure to find org.springframework.boot:spring-boot-tools:jar:1.1.7.RELEASE in http://repo.maven.apache.org/maven2 was cached in the
local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
        at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:232)
        at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.gatherDownloads(DefaultArtifactResolver.java:599)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:518)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:436)
        ... 26 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
O:\Clouds\Dropbox\Repositories\git\Spring Comparison Test\Boot>mvn -X clean install
3个回答

5
问题在于您使用了一个存在但由于某种原因无法下载的版本(下载问题/代理等)。
在本地存储库${HOME}/.m2/repository/org.springframewokr/boot中,您需要删除文件夹spring-boot-tools并尝试重新构建。
此外,所使用的工件不是jar文件,而是一个多模块构建的父级,不能用作依赖项。您需要检查文档以确定您需要使用哪种工件。
更新:
根据文档,您需要以不同的方式定义pom:
<project...>

  <dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>...</version>
    </dependency>
  </dependencies>
</project>

即使我尝试过,这种情况仍然发生。 - mangusbrother
我清空了pom文件,重新添加了我的依赖项,现在它不再抱怨了。 - mangusbrother

0
如果我查看Maven网站:http://mvnrepository.com/artifact/org.springframework.boot 我找不到1.1.7.RELEASE版本,只有1.1.6.RELEASE版本。请尝试:
<dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-tools</artifactId>
        <version>1.1.6.RELEASE</version>
    </dependency>
</dependencies>

我在 search.maven.org 上找到了该版本。即使使用您建议的版本,情况仍然是一样的。 - mangusbrother
我甚至尝试了基本的spring-web依赖项。不一定非要使用Spring Boot。 - mangusbrother

0
你只是想让Maven工作吗?那么或许可以尝试使用主流/常见的依赖库,例如Log4j或Junit?我试图按照堆栈跟踪中显示的URL(http://repo.maven.apache.org/maven2)进行操作,并遍历项目以查看POM等内容 - 下面是我看到的内容(没有提到你的构件!)。
<project ....
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-parent</artifactId>
<version>1.1.7.RELEASE</version>
....

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接