使用Gradle,Spring Boot插件和Nexus在安装任务期间找不到工件

时间:2015-04-14 12:36:57

标签: gradle spring-boot nexus

Gradle 项目中使用 Spring Boot插件 Nexus repo管理器,我在{{1}期间遇到ArtifactNotFoundException任务。

为了提供一些解释,如线程Unable to publish to local maven repo when using Gradle and Spring Boot中所述,为了避免Spring Boot错误,我在安装任务中添加了与install pom的关系。

这样做,我面对以下堆栈跟踪:

spring-boot-started-parent

使用$ gradle install --stacktrace :compileJava :processResources UP-TO-DATE :classes :jar :installDownloading: org/springframework/boot/spring-boot-starter-parent/1.2.3.RELEASE/spring-boot-starter-parent-1.2.3.RELEASE.pom from repository central at http://central Error transferring file: central Downloading: org/springframework/boot/spring-boot-starter-parent/1.2.3.RELEASE/spring-boot-starter-parent-1.2.3.RELEASE.pom from repository central at http://repo1.maven.org/maven2 Error transferring file: repo1.maven.org FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':install'. > Could not publish configuration 'archives' > Unable to initialize POM pom-default.xml: Cannot find parent: org.springframework.boot:spring-boot-starter-parent for project: com.mygroup:myjar:jar:1.0.6 for project com.mygroup:myjar:jar:1.0.6 * Try: Run with --info or --debug option to get more log output. * Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':install'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:296) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:86) at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61) at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23) at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:67) at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:61) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:54) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:148) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:105) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:85) at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:81) at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33) at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:39) at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:35) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69) at org.gradle.util.Swapper.swap(Swapper.java:38) at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:60) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45) at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:184) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:30) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:125) at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:51) at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155) at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128) at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116) at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) Caused by: org.gradle.api.artifacts.PublishException: Could not publish configuration 'archives' at org.gradle.api.tasks.Upload.upload(Upload.java:66) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:570) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:553) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) ... 66 more Caused by: Unable to initialize POM pom-default.xml: Cannot find parent: org.springframework.boot:spring-boot-starter-parent for project: com.mygroup:myjar:jar:1.0.6 for project com.mygroup:myjar:jar:1.0.6 at org.apache.maven.artifact.ant.Pom.initialiseMavenProject(Pom.java:217) at org.apache.maven.artifact.ant.AbstractArtifactTask.initializePom(AbstractArtifactTask.java:527) at org.apache.maven.artifact.ant.InstallDeployTaskSupport.initializePom(InstallDeployTaskSupport.java:59) at org.apache.maven.artifact.ant.InstallTask.doExecute(InstallTask.java:50) at org.gradle.api.publication.maven.internal.ant.CustomInstallTask.doExecute(CustomInstallTask.java:34) at org.apache.maven.artifact.ant.AbstractArtifactTask.execute(AbstractArtifactTask.java:751) at org.gradle.api.publication.maven.internal.ant.AbstractMavenResolver.execute(AbstractMavenResolver.java:111) at org.gradle.api.publication.maven.internal.ant.AbstractMavenResolver.publish(AbstractMavenResolver.java:102) at org.gradle.api.publication.maven.internal.ant.AbstractMavenResolver.publish(AbstractMavenResolver.java:80) at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyDependencyPublisher.publish(DefaultIvyDependencyPublisher.java:42) at org.gradle.api.internal.artifacts.ivyservice.IvyBackedArtifactPublisher$1.execute(IvyBackedArtifactPublisher.java:79) at org.gradle.api.internal.artifacts.ivyservice.IvyBackedArtifactPublisher$1.execute(IvyBackedArtifactPublisher.java:54) at org.gradle.internal.Transformers$3.transform(Transformers.java:131) at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:61) at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:39) at org.gradle.api.internal.artifacts.ivyservice.IvyBackedArtifactPublisher.publish(IvyBackedArtifactPublisher.java:54) at org.gradle.api.tasks.Upload.upload(Upload.java:64) ... 74 more Caused by: org.apache.maven.project.ProjectBuildingException: Cannot find parent: org.springframework.boot:spring-boot-starter-parent for project: com.mygroup:myjar:jar:1.0.6 for project com.mygroup:myjar:jar:1.0.6 at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1396) at org.apache.maven.project.DefaultMavenProjectBuilder.buildInternal(DefaultMavenProjectBuilder.java:823) at org.apache.maven.project.DefaultMavenProjectBuilder.buildFromSourceFileInternal(DefaultMavenProjectBuilder.java:508) at org.apache.maven.project.DefaultMavenProjectBuilder.build(DefaultMavenProjectBuilder.java:200) at org.apache.maven.artifact.ant.Pom.initialiseMavenProject(Pom.java:211) ... 90 more Caused by: org.apache.maven.project.ProjectBuildingException: POM 'org.springframework.boot:spring-boot-starter-parent' not found in repository: Unable to download the artifact from any repository org.springframework.boot:spring-boot-starter-parent:pom:1.2.3.RELEASE from the specified remote repositories: central (http://repo1.maven.org/maven2) for project org.springframework.boot:spring-boot-starter-parent at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:605) at org.apache.maven.project.DefaultMavenProjectBuilder.assembleLineage(DefaultMavenProjectBuilder.java:1392) ... 94 more Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException: Unable to download the artifact from any repository org.springframework.boot:spring-boot-starter-parent:pom:1.2.3.RELEASE from the specified remote repositories: central (http://repo1.maven.org/maven2) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:228) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:90) at org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository(DefaultMavenProjectBuilder.java:558) ... 95 more Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to download the artifact from any repository at org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact(DefaultWagonManager.java:404) at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:216) ... 97 more 时,我也会发现:

--debug

乍一看,错误似乎很容易理解:在Nexus上找不到工件(11:10:30.612 [ERROR] [system.err] Downloading: org/springframework/boot/spring-boot-starter-parent/1.2.3.RELEASE/spring-boot-starter-parent-1.2.3.RELEASE.pom from repository central at http://central 11:10:32.887 [ERROR] [system.err] Error transferring file: central 11:10:32.888 [INFO] [system.out] [WARNING] Unable to get resource 'org.springframework.boot:spring-boot-starter-parent:pom:1.2.3.RELEASE' from repository central (http://central): Error transferring file: central 11:10:32.889 [ERROR] [system.err] Downloading: org/springframework/boot/spring-boot-starter-parent/1.2.3.RELEASE/spring-boot-starter-parent-1.2.3.RELEASE.pom from repository central at http://repo1.maven.org/maven2 11:10:35.152 [ERROR] [system.err] Error transferring file: repo1.maven.org 11:10:35.153 [INFO] [system.out] [WARNING] Unable to get resource 'org.springframework.boot:spring-boot-starter-parent:pom:1.2.3.RELEASE' from repository central (http://repo1.maven.org/maven2): Error transferring file: repo1.maven.org 11:10:35.156 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] An error has occurred while processing the Maven artifact tasks. Diagnosis: Unable to initialize POM pom-default.xml: Cannot find parent: org.springframework.boot:spring-boot-starter-parent for project: com.toto:myproject:jar:1.0.6 for project com.toto:myproject:jar:1.0.6 Unable to download the artifact from any repository )。 问题是我的Nexus已配置为访问Maven Central以获取依赖项(如果未托管)

我检查了我的组,工件ID和版本是否正确(spring-boot-starter-parent)。 没问题,我可以在Maven Central网站上找到这种依赖。

要检查问题是否来自org.springframework.boot:spring-boot-starter-parent:pom:1.2.3.RELEASE的声明方式(在安装任务中,而不是spring-boot-starter-parent部分),我创建了一个非常简单的Maven项目,其中包含以下内容: dependencies

pom.xml

此项目及其pom没有问题,spring-boot-starter-parent被检索,添加到代理仓库的Nexus存储,目标是Maven Central:

enter image description here

不是Gradle 的情况,这让我觉得这个问题是特定于Gradle的。

作为解决方法,如果我在Nexus中托管工件,Gradle构建工作正常
作为一种解决方法,如果依赖项存在于我的本地仓库中,则Gradle构建工作正常 但是,如果有人对如何解决问题有一些线索,那么我将不允许在每个新版本中手动添加依赖版本。


编辑20150415

为了帮助理解这个问题,这是我的<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.2.3.RELEASE</version> </parent> <groupId>toto</groupId> <artifactId>maven-test-project</artifactId> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name>Draft project</name> </project>

build.gradle

要回答几条评论,并检查我的Nexus是否已被充分声明,我从本地存储库和Gradle缓存中删除了// Declare elements required by the build itself buildscript { project.ext { bootVersion = '1.2.3.RELEASE' } repositories { mavenLocal() maven { url 'http://mynexus.net.intra:8080/nexus/content/groups/public/' credentials { username 'someUsername' password 'somePassword' } } } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${project.bootVersion}") } } apply plugin: 'java' targetCompatibility = 1.8 sourceCompatibility = 1.8 apply plugin: 'eclipse' apply plugin: 'maven' apply plugin: 'spring-boot' // To configure the Maven plugin project.group = 'com.mygroup' // If project.version is not set, artifactId is taken by default, from folder name project.version = '1.0.6' // required to install the jar on local Maven repo, when using the Spring Boot plugin // check https://stackoverflow.com/questions/23665976/unable-to-publish-to-local-maven-repo-when-using-gradle-and-spring-boot // !!!! Careful !!!! You could be forced to manually add the dependency declared in this section in your local repo, to have the script work install { repositories.mavenInstaller { pom.project { parent { groupId 'org.springframework.boot' artifactId 'spring-boot-starter-parent' version "${project.bootVersion}" } } } } jar { baseName = 'myjar' } repositories { mavenLocal() maven { url 'http://mynexus.fr.net.intra:8080/nexus/content/groups/public/' credentials { username 'someUsername' password 'somePassword' } } } dependencies { compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework.boot:spring-boot-starter-data-jpa") compile("org.hibernate:hibernate-entitymanager") compile("oracle:ojdbc6:12.1.0.1") testCompile("junit:junit") } sourceSets { main { java { srcDir 'src/java' } resources { srcDir 'conf/java' } } } ,然后我重新启动了{{1} }。 这是日志:

ojdbc6

从ojdbc6依赖关系中可以看出, Nexus用于解决它
在我看来,在安装任务定义中没有考虑我的Nexus声明。
我将在本节中搜索读取此声明的方法。

谢谢, 托马斯

3 个答案:

答案 0 :(得分:1)

我做了一些调查,现在我相信这个问题来自Gradle install任务中的错误。

首先,这是我的Maven settings.xml中的Nexus配置:

[...]
<mirrors>

    <mirror>
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://mynexus.net.intra:8080/nexus/content/groups/public/</url>
    </mirror>

[...]
</mirrors>

[...]
<profiles>
    <profile>
        <id>nexus</id>
        <!-- Enable snapshots for the built in central repo to direct -->
        <!-- all requests to nexus via the mirror -->
        <repositories>
            <repository>
                <id>central</id>
                <url>http://central</url>
                <releases>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>central</id>
                <url>http://central</url>
                <releases>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>

    [...]
</profiles>

[...]

现在,这是install task中的经典问题,使用--debug选项:

14:11:38.995 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':install'
14:11:38.996 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ':install' is up-to-date
14:11:38.998 [INFO] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Executing task ':install' (up-to-date check took 0.002 secs) due to:
  Task has not declared any outputs.
14:11:38.999 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':install'.
14:11:39.000 [INFO] [org.gradle.api.Task] Publishing configuration: configuration ':archives'
14:11:39.005 [INFO] [org.gradle.api.internal.artifacts.ivyservice.DefaultIvyDependencyPublisher] Publishing to org.gradle.api.publication.maven.internal.ant.BaseMavenInstaller@71a6c033
14:11:39.034 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Adding reference: ant.PropertyHelper
14:11:39.035 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Detected Java version: 1.8 in: C:\tools\Java\jdk1.8.0_25\jre
14:11:39.035 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Detected OS: Windows 7
14:11:39.044 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Adding reference: ant.ComponentHelper
14:11:39.048 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Project base dir set to: C:\workspace\myjar
14:11:39.084 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Maven Ant Tasks version: 2.1.3
14:11:39.088 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\Users\536355\.m2\settings.xml
14:11:39.129 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\workspace\maven-3.0.4\conf\settings.xml
14:11:39.257 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Adding reference: org.codehaus.plexus.PlexusContainer
14:11:39.318 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\Users\536355\.m2\settings.xml
14:11:39.320 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\workspace\maven-3.0.4\conf\settings.xml
14:11:39.345 [ERROR] [system.err] Downloading: org/springframework/boot/spring-boot-starter-parent/1.2.3.RELEASE/spring-boot-starter-parent-1.2.3.RELEASE.pom from repository central at http://central
14:11:41.623 [ERROR] [system.err] Error transferring file: central
14:11:41.623 [INFO] [system.out] [WARNING] Unable to get resource 'org.springframework.boot:spring-boot-starter-parent:pom:1.2.3.RELEASE' from repository central (http://central): Error transferring file: central
14:11:41.624 [ERROR] [system.err] Downloading: org/springframework/boot/spring-boot-starter-parent/1.2.3.RELEASE/spring-boot-starter-parent-1.2.3.RELEASE.pom from repository central at http://repo1.maven.org/maven2
14:11:43.894 [ERROR] [system.err] Error transferring file: repo1.maven.org
14:11:43.895 [INFO] [system.out] [WARNING] Unable to get resource 'org.springframework.boot:spring-boot-starter-parent:pom:1.2.3.RELEASE' from repository central (http://repo1.maven.org/maven2): Error transferring file: repo1.maven.org
14:11:43.897 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] An error has occurred while processing the Maven artifact tasks.
 Diagnosis:

Unable to initialize POM pom-default.xml: Cannot find parent: org.springframework.boot:spring-boot-starter-parent for project: com.mygroup:myjar:jar:1.0.6 for project com.mygroup:myjar:jar:1.0.6
Unable to download the artifact from any repository


14:11:43.898 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':install'

我们看到Gradle首先尝试从http://central获取依赖关系,然后从http://repo1.maven.org/maven2(通常的Maven Central)获取依赖关系。

如果我更改了我的Maven settings.xml,将中央存储库的网址从http://central修改为http://toto,则日志会变为:

11:21:29.746 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ':install' is up-to-date
11:21:29.747 [INFO] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Executing task ':install' (up-to-date check took 0.001 secs) due to:
  Task has not declared any outputs.
11:21:29.748 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':install'.
11:21:29.749 [INFO] [org.gradle.api.Task] Publishing configuration: configuration ':archives'
11:21:29.757 [INFO] [org.gradle.api.internal.artifacts.ivyservice.DefaultIvyDependencyPublisher] Publishing to org.gradle.api.publication.maven.internal.ant.BaseMavenInstaller@3bd6b327
11:21:29.783 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Adding reference: ant.PropertyHelper
11:21:29.784 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Detected Java version: 1.8 in: C:\tools\Java\jdk1.8.0_25\jre
11:21:29.784 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Detected OS: Windows 7
11:21:29.794 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Adding reference: ant.ComponentHelper
11:21:29.797 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Project base dir set to: C:\workspace\myjar
11:21:29.830 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Maven Ant Tasks version: 2.1.3
11:21:29.833 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\Users\536355\.m2\settings.xml
11:21:29.873 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\workspace\maven-3.0.4\conf\settings.xml
11:21:29.992 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Adding reference: org.codehaus.plexus.PlexusContainer
11:21:30.048 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\Users\536355\.m2\settings.xml
11:21:30.051 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\workspace\maven-3.0.4\conf\settings.xml
11:21:30.075 [ERROR] [system.err] Downloading: org/springframework/boot/spring-boot-starter-parent/1.2.3.RELEASE/spring-boot-starter-parent-1.2.3.RELEASE.pom from repository central at http://toto
11:21:30.088 [ERROR] [system.err] Error transferring file: toto
11:21:30.089 [INFO] [system.out] [WARNING] Unable to get resource 'org.springframework.boot:spring-boot-starter-parent:pom:1.2.3.RELEASE' from repository central (http://toto): Error transferring file: toto
11:21:30.090 [ERROR] [system.err] Downloading: org/springframework/boot/spring-boot-starter-parent/1.2.3.RELEASE/spring-boot-starter-parent-1.2.3.RELEASE.pom from repository central at http://repo1.maven.org/maven2
11:21:32.354 [ERROR] [system.err] Error transferring file: repo1.maven.org
11:21:32.355 [INFO] [system.out] [WARNING] Unable to get resource 'org.springframework.boot:spring-boot-starter-parent:pom:1.2.3.RELEASE' from repository central (http://repo1.maven.org/maven2): Error transferring file: repo1.maven.org
11:21:32.357 [INFO] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] An error has occurred while processing the Maven artifact tasks.
 Diagnosis:

Unable to initialize POM pom-default.xml: Cannot find parent: org.springframework.boot:spring-boot-starter-parent for project: com.mygroup:myjar:jar:1.0.6 for project com.mygroup:myjar:jar:1.0.6
Unable to download the artifact from any repository


11:21:32.358 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':install'

可以看出,Gradle现在首先尝试从http://toto获取依赖关系,然后它仍然转到Maven Central。
这意味着Gradle:

  • 有效地阅读了我的Maven settings.xml
  • 无法在安装任务中访问Maven镜像定义

对我而言,主要问题在于

最后,如果我现在将spring-boot-starter-parent依赖项添加到我的maven本地存储库,则日志会变为:

14:14:08.474 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Starting to execute task ':install'
14:14:08.474 [DEBUG] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Determining if task ':install' is up-to-date
14:14:08.475 [INFO] [org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter] Executing task ':install' (up-to-date check took 0.001 secs) due to:
  Task has not declared any outputs.
14:14:08.475 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter] Executing actions for task ':install'.
14:14:08.476 [INFO] [org.gradle.api.Task] Publishing configuration: configuration ':archives'
14:14:08.481 [INFO] [org.gradle.api.internal.artifacts.ivyservice.DefaultIvyDependencyPublisher] Publishing to org.gradle.api.publication.maven.internal.ant.BaseMavenInstaller@74eaee53
14:14:08.504 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Adding reference: ant.PropertyHelper
14:14:08.504 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Detected Java version: 1.8 in: C:\tools\Java\jdk1.8.0_25\jre
14:14:08.505 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Detected OS: Windows 7
14:14:08.515 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Adding reference: ant.ComponentHelper
14:14:08.519 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Project base dir set to: C:\workspace\myjar
14:14:08.555 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Maven Ant Tasks version: 2.1.3
14:14:08.558 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\Users\536355\.m2\settings.xml
14:14:08.599 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\workspace\maven-3.0.4\conf\settings.xml
14:14:08.725 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] Adding reference: org.codehaus.plexus.PlexusContainer
14:14:08.798 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\Users\536355\.m2\settings.xml
14:14:08.800 [DEBUG] [org.gradle.api.internal.project.ant.AntLoggingAdapter] [ant:null] Loading Maven settings file: C:\workspace\maven-3.0.4\conf\settings.xml
14:14:08.892 [INFO] [system.out] [INFO] Installing C:\workspace\myjar\target\libs\myjar-1.0.6.jar to C:\workspace\maven-3.0.4\repository\com\mygroup\myjar\1.0.6\myjar-1.0.6.jar
14:14:08.905 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':install'

在这种情况下,构建成功。

因此,根据这些线索,我会建议Gradle安装任务中存在错误,严重考虑Maven settings.xml中的repo配置。

答案 1 :(得分:0)

您的项目配置实际上与Nexus没有对话。似乎Gradle任务正在向Maven转移,而且它没有通过settings.xml配置连接到Nexus公共组,而是仍然尝试直接访问Central Repository。

您可能需要配置Maven,也可能还要Gradle连接到Nexus。两者的详细信息可以在in the Nexus documentation about configuring build tools.

找到

答案 2 :(得分:0)

对我来说,帮助从gradle 2.2切换到2.9。

您使用的是哪个版本?

在切换到弹簧启动1.3.0后,我再也不需要这个块了

install {
    repositories.mavenInstaller {
        pom.project {
          parent {
            groupId 'org.springframework.boot'
            artifactId 'spring-boot-starter-parent'
            version "${project.bootVersion}"
          }
        }
    }
}