Java Maven 不下载依赖项的 jars
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26097261/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Maven not downloading jars for dependencies
提问by mangusbrother
I am trying to set up Maven on my Windows machine. I tried both 3.2.3 and 3.1.1. I installed the m2eclipse plugin in my eclipse.
我正在尝试在我的 Windows 机器上设置 Maven。我尝试了 3.2.3 和 3.1.1。我在我的 eclipse 中安装了 m2eclipse 插件。
I places the following dependencies in my pom.xml (just as a sample)
我将以下依赖项放在我的 pom.xml 中(仅作为示例)
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-tools</artifactId>
<version>1.1.7.RELEASE</version>
</dependency>
</dependencies>
Eclipse gives the error: Missing artifact org.springframework.boot:spring-boot-tools:jar:1.1.7.RELEASE
Eclipse 给出了错误: Missing artifact org.springframework.boot:spring-boot-tools:jar:1.1.7.RELEASE
In my .m2 repository I have the .pom file, the .jar.lastUpdated file but no actual .jar file
在我的 .m2 存储库中,我有 .pom 文件、.jar.lastUpdated 文件但没有实际的 .jar 文件
When I execute mvn -X clean install
I have the following stack trace
当我执行时,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
采纳答案by khmarbaise
The problem is you have used a version which exsts but couldn't be downloaded for whatever reason (Download problems / proxies etc.).
问题是您使用了一个存在但由于某种原因(下载问题/代理等)而无法下载的版本。
Within your local repository ${HOME}/.m2/repository/org.springframewokr/boot
you need to delete the folder spring-boot-tools
and try to rebuild.
在您的本地存储库中,${HOME}/.m2/repository/org.springframewokr/boot
您需要删除该文件夹spring-boot-tools
并尝试重建。
Apart from that the used artifacts is not a jar
file it is a parent of a multi module build instead which can't be used as a dependency. You need to check the documentation which kind of artifacts you have to use.
除此之外,使用的工件不是jar
文件,它是多模块构建的父项,不能用作依赖项。您需要检查文档,您必须使用哪种工件。
Update:
更新:
Based on the docs you have to define your pom differently:
根据文档,您必须以不同的方式定义 pom:
<project...>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>...</version>
</dependency>
</dependencies>
</project>
回答by Vincent Beltman
If I look at the maven website: http://mvnrepository.com/artifact/org.springframework.boot
如果我查看 Maven 网站:http: //mvnrepository.com/artifact/org.springframework.boot
I can't find the 1.1.7.RELEASE version. Only the 1.1.6.RELEASE version. Try:
我找不到 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>
回答by welterw8
Are you simply trying to get Maven working? Then perhaps try a mainstream/common dependency e.g. Log4j or Junit? I tried to follow the URL that is shown in the stack trace (http://repo.maven.apache.org/maven2) and traverse the projects to look at the POM etc - below is what I see (no mention of your artifact!).
你只是想让 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>
....