我在一个多java项目中使用spring 2。
我尝试构建我的主库(还没有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"]
}在我的梯度/包装里,我有
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我犯了错误
原因: org.gradle.api.internal.plugins.PluginApplicationException:未能应用插件id 'org.springframework.boot‘ 原因: org.gradle.api.GradleException: Spring插件需要Gradle 4.0或更高版本。当前版本是第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')
}发布于 2017-12-12 03:17:26
您可能使用本地安装的gradle构建项目,而不是使用包装器,即使用gradle build而不是./gradlew build。
发布于 2018-04-17 18:25:41
这些是我为解决同样的问题而采取的步骤。
我希望这能帮上忙!
我从另一个项目复制了我的gradle包装文件夹,并编辑了./gradle/ wrapper /gradle-wrapper.properties
发布于 2018-12-08 20:56:32
我正在运行Eclipse2018-2019/STS 4.0/Buildship Gradle 3.0。我通过配置Eclipse > Gradle > Properties来解决这个问题。
具体地说:

https://stackoverflow.com/questions/47764787
复制相似问题