【发布时间】:2018-05-25 16:13:42
【问题描述】:
我使用spring boot 2。在一个多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"]
}
在我的 gradle/wrapper 中,我有
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 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')
}
【问题讨论】:
-
可以在构建文件中添加
println "Gradle version: "+GradleVersion.current().getVersion()确认版本 -
2.13...奇怪的是我在我的 .gradle/wrapper/dists/gradle-2.13-bin/ 中删除了 2.13 ...当我重新加载项目时...我似乎再次下载了 2.13
-
没有访问系统很难说,但有几个想法。 zipStorePath 中有旧的 2.13 版本吗?你可以在 gradle 文件中添加一个包装器任务吗?
task wrapper(type: Wrapper) { gradleVersion = '4.2' }
标签: spring-boot gradle