无法开始使用SpringBoot和Gradle

bal*_*erc 7 gradle spring-boot

我是Java,Gradle和Spring的新手.

我使用以下gradle脚本设置了一个新项目:

buildscript {
    repositories {
        maven { url "http://repo.spring.io/snapshot" }
        maven { url "http://repo.spring.io/milestone" }
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.0.BUILD-SNAPSHOT")
    }
}

apply plugin: 'java'
apply plugin: 'spring-boot'

repositories {
    maven { url "http://repo.spring.io/snapshot" }
    maven { url "http://repo.spring.io/milestone" }
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    testCompile("org.springframework.boot:spring-boot-starter-test")
}
Run Code Online (Sandbox Code Playgroud)

尝试使用上面的脚本进行构建时,我收到以下错误:

E:\Projects\SpringAppTutorial>gradlew

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'SpringAppTutorial'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.3.0.BUILD-SNAPSHOT.
    Required by:
        :SpringAppTutorial:unspecified
     > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:1.3.0.BUILD-SNAPSHOT.
        > Could not parse POM http://repo.spring.io/snapshot/org/springframework/boot/spring-boot-gradle-plugin/1.3.0.BUILD-SNAPSHOT/spring-boot-gradle-plugin-1.3.0.BUILD-20150531.081700-179.pom
           > Could not resolve org.springframework.boot:spring-boot-tools:1.3.0.BUILD-SNAPSHOT.
              > Could not resolve org.springframework.boot:spring-boot-tools:1.3.0.BUILD-SNAPSHOT.
                 > Could not parse POM http://repo.spring.io/snapshot/org/springframework/boot/spring-boot-tools/1.3.0.BUILD-SNAPSHOT/spring-boot-tools-1.3.0.BUILD-20150531.081700-180.pom
                    > Could not resolve org.springframework.boot:spring-boot-parent:1.3.0.BUILD-SNAPSHOT.
                       > Could not resolve org.springframework.boot:spring-boot-parent:1.3.0.BUILD-SNAPSHOT.
                          > Could not parse POM http://repo.spring.io/snapshot/org/springframework/boot/spring-boot-parent/1.3.0.BUILD-SNAPSHOT/spring-boot-parent-1.3.0.BUILD-20150531.081700-180.pom
                             > Could not resolve org.springframework.boot:spring-boot-dependencies:1.3.0.BUILD-SNAPSHOT.
                                > Could not resolve org.springframework.boot:spring-boot-dependencies:1.3.0.BUILD-SNAPSHOT.
                                   > Could not parse POM http://repo.spring.io/snapshot/org/springframework/boot/spring-boot-dependencies/1.3.0.BUILD-SNAPSHOT/spring-boot-dependencies-1.3.0.BUILD-20150531.081700-181.pom
                                      > Could not find org.springframework.data:spring-data-releasetrain:Fowler-RELEASE.
                                        Searched in the following locations:
                                            http://repo.spring.io/snapshot/org/springframework/data/spring-data-releasetrain/Fowler-RELEASE/spring-data-releasetrain-Fowler-RELEASE.pom
                                            http://repo.spring.io/snapshot/org/springframework/data/spring-data-releasetrain/Fowler-RELEASE/spring-data-releasetrain-Fowler-RELEASE.jar
                                            http://repo.spring.io/milestone/org/springframework/data/spring-data-releasetrain/Fowler-RELEASE/spring-data-releasetrain-Fowler-RELEASE.pom
                                            http://repo.spring.io/milestone/org/springframework/data/spring-data-releasetrain/Fowler-RELEASE/spring-data-releasetrain-Fowler-RELEASE.jar

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 15.726 secs

E:\Projects\SpringAppTutorial>
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?

ska*_*man 5

您应该使用spring-boot gradle插件的发行版-您的脚本使用某种开发快照版本字符串。

即尝试

dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE")
}
Run Code Online (Sandbox Code Playgroud)

(来自http://docs.spring.io/spring-boot/docs/current/reference/html/build-tool-plugins-gradle-plugin.html

假设可行,您还应该可以摆脱本节的内容:

repositories {
   maven { url "http://repo.spring.io/snapshot" }
   maven { url "http://repo.spring.io/milestone" }
}
Run Code Online (Sandbox Code Playgroud)