编译发现gradle的错误版本

rob*_*del 3 gradle spring-boot

我使用spring boot2。在一个多Java项目中。

我尝试构建我的主库(尚无Java文件)

apply plugin: 'java-library-distribution'


plugins {
    id 'org.springframework.boot' version '2.0.0.M7'
}

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}


dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.0.0.M7'
    compile group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
        testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.0.0.M7'
}

distributions {
    main{
        baseName = 'common-model'
    }
}

sourceCompatibility = 1.8

tasks.withType(JavaCompile) {
    options.compilerArgs = ["-Xlint:unchecked", "-Xlint:deprecation", "-parameters"]
}
Run Code Online (Sandbox Code Playgroud)

在我的gradle /包装器中,我有

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-bin.zip
Run Code Online (Sandbox Code Playgroud)

我得到的错误

引起原因:org.gradle.api.internal.plugins.PluginApplicationException:无法应用插件[id'org.springframework.boot']

原因:org.gradle.api.GradleException:Spring Boot插件需要Gradle 4.0或更高版本。当前版本是Gradle 2.13

我找不到任何2.13版本

在我的主要项目中

buildscript {
    ext {
        springBootVersion = '2.0.0.M7'
    }
    repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

mainClassName = 'com.zirgon.EmailApplication'

group = 'com.zirgon'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

tasks.withType(JavaCompile) {
    options.compilerArgs = ["-Xlint:unchecked", "-Xlint:deprecation", "-parameters"]
}

repositories {
    mavenCentral()
    maven { url "https://repo.spring.io/snapshot" }
    maven { url "https://repo.spring.io/milestone" }
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')

    compile project(':common-model')
    compile('org.springframework.boot:spring-boot-starter-mail')

    compile group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
    testCompile('org.springframework.boot:spring-boot-starter-test')
}
Run Code Online (Sandbox Code Playgroud)

Pan*_*dge 9

您可能正在使用本地安装的gradle构建项目,而不是使用包装器,即使用gradle build代替./gradlew build