无法在Gradle中升级Spring Boot版本 [英] Unable to upgrade spring boot version in gradle

查看:406
本文介绍了无法在Gradle中升级Spring Boot版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地安装了gradle 4.7,下面是我的gradle.build,它可以正常工作.gradle构建成功,使用gradle插件4.7版

I am having gradle 4.7 installed on my local and following is my gradle.build which works fine. gradle build is successful on this with gradle plugin version 4.7

buildscript {
        ext {
            springBootVersion = '1.5.2.RELEASE'
        }
        repositories {
            maven { url "https://artifactory.domain.com/mavenrepo" }
            maven { url "https://artifactory.domain.com/maven.atlassian.com-cache" }
        }
        dependencies {
            classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
            classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.6"
        }
    }
    
    apply plugin: "com.github.sherter.google-java-format"
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'idea'
    apply plugin: 'org.springframework.boot'
    
    apply plugin: 'findbugs'
    apply plugin: 'maven-publish'
    
    group = 'com.domain.xyz.myapp'
    version = '1.0.1-SNAPSHOT'
    
    repositories {
        maven { url "https://artifactory.domain.com/mavenrepo" }
    }
    project.tasks.findAll { it.name.startsWith("publish") } .each { it.dependsOn assemble }
    
    springBoot {
        classifier = 'boot'
    }
    
    publishing {
        publications {
            maven(MavenPublication) {
                artifact ("$buildDir/libs/$project.name-$version-boot.jar") {
                    classifier = 'boot'
                }
            }
        }
        
        repositories {
            maven {
                url "http://artifactory.xyz.com:8080/project-snapshots"
                 credentials {
                    username = "publish-username"
                    password = "publish-password"
                }
            }
        }
    }
    
    
    tasks.withType(FindBugs) {
        reports {
            xml.enabled false
            html.enabled true
        }
    }
    
    configurations {
        all*.exclude group: 'javax.servlet', module: 'servlet-api'
    }
    
    dependencies {
        compileOnly('org.projectlombok:lombok:1.16.14')
        compile('org.springframework.boot:spring-boot-starter-actuator')
        compile('org.springframework.boot:spring-boot-starter-cache')
        compile('org.springframework.boot:spring-boot-starter-data-jpa')
        compile('org.springframework.boot:spring-boot-starter-data-ldap')
        compile('org.springframework.boot:spring-boot-starter-web')
        compile('org.springframework.boot:spring-boot-starter-batch')
        compile('org.springframework.boot:spring-boot-starter-jdbc')
        compile('org.springframework:spring-web')
        compile('com.google.guava:guava:r05')
      runtime('mysql:mysql-connector-java:8.0.16')
        runtime('org.hsqldb:hsqldb:2.3.3')
        runtime('org.springframework.boot:spring-boot-devtools')
        testCompile('org.springframework.boot:spring-boot-starter-test')
        testCompile('com.jayway.jsonpath:json-path')
        compile('com.jcraft:jsch:0.1.53')
        compile('net.sourceforge.jtds:jtds:1.3.1')
        compile('jcifs:jcifs:1.3.17')
        compile('org.apache.camel:camel-core:2.15.0')
        compile('com.github.ulisesbocchio:jasypt-spring-boot-starter:1.9')
        compile('io.micrometer:micrometer-registry-prometheus:1.0.3')
        compile('io.micrometer:micrometer-spring-legacy:1.0.3')
    }

当我运行gradle build时,它运行良好.

When i run gradle build it works fine.

但是现在我需要将SpringBootVersion升级到2.4.3(最新),并用以下内容替换文件中的第三行:

But now I need to upgrade my SpringBootVersion to 2.4.3(latest) and I replace the third line in file with following:

springBootVersion = '2.4.3'

但是我收到以下错误消息:

But I get following error:

无法应用插件[id'org.springframework.boot'] Spring Boot插件需要Gradle 5(仅适用于5.6.x)或Gradle 6(6.3或更高版本).这当前版本是Gradle 4.7

Failed to apply plugin [id 'org.springframework.boot'] Spring Boot plugin requires Gradle 5 (5.6.x only) or Gradle 6 (6.3 or later). The current version is Gradle 4.7

如果gradle build在4.7上可以正常工作,那么4.7中的 apply插件行:'org.springframework.boot'也可以,并且4.7可以识别它,为什么会要求我升级到4.7可以构建到更高版本的时候?我缺少什么?如何正确升级Spring Boot版本并解决它?

If gradle build works fine with 4.7, then the the line apply plugin: 'org.springframework.boot'in 4.7 is also fine and 4.7 can recognise it, why would it ask me to upgrade to later version when 4.7 can build it?What am I missing?How can I upgrade Spring Boot version properly and resolve it?

推荐答案

由于较新的spring boot版本与较旧的gradle版本不兼容,因此您将需要更新gradle.

You are going to need to update gradle, as newer spring boot versions are incompatible with older versions of gradle.

您可以手动下载新的gradle,也可以使用gradle包装器为您的项目设置版本.

You can either download the new gradle manually or use gradle wrapper to set the version for your project.

您可以通过使用命令来完成此操作

You can do this by using the command

渐变包装器--gradle-version 6.8.3 或者 ./gradle wrapper --gradle-version 6.8.3

有时候gradle的版本太旧而无法进行更新跳转,无论如何,您都必须手动下载新版本(如果我没记错的话,等级2可能太旧而无法直接升至6.)

Sometimes gradle will be too old of a version to make an update jump and you will have to download a new version manually anyway (gradle 2 may be too old to go straight to 6 if I remember right.)

要在设置包装后使用包装器,只需用gradlew替换gradle命令.示例:

To use your wrapper after it is set up just replace your gradle commands with gradlew. Example:

gradlew bootRun

这篇关于无法在Gradle中升级Spring Boot版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆