有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

SpringGradle升级问题:java。lang.IllegalArgumentException:版本不能为null或为空

我们在将gradle 5.6升级到gradle 7.2时面临这个问题

我们有一个简单的spring启动项目(sub1)和一个内部spring库项目(Sub2)。而sub2是渐变弹簧库,它依赖于sub1。两个项目都使用相同的gradle和spring启动版本

此外,我们正在尝试将SpringCloud升级到最新版本,这需要gradle升级和SpringBoot升级。当前版本如下所示

  1. 格拉德尔-7.2
  2. 弹簧-2.5.2
  3. 大摇大摆-2.9.2

当我尝试点击招摇过市url时出现以下错误

java.lang.IllegalArgumentException: Version must not be null o empty

Spring boot横幅为空,不显示版本。我们怀疑这可能是问题所在

Swagger主页显示以下错误:

Failed to load API definition

渐变文件

    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4+'
    }
}

plugins {
    id "org.sonarqube" version "2.8"
    id "com.gorylenko.gradle-git-properties" version "2.2.2"
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
apply plugin: "jacoco"

sourceCompatibility = 1.8

repositories {
    mavenCentral()

}

configurations {
  implementation.canBeResolved = true
}

jar {
    archiveVersion = "${project.findProperty('APP_VERSION') ?: 'MANUAL_BUILD'}"
    dependsOn configurations.runtimeClasspath
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
    from {
        (configurations.runtimeClasspath-configuration.implementation).collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }

}

dependencies {
    implementation('org.springframework:spring-webmvc:5.3.8')
    implementation('org.apache.tomcat.embed:tomcat-embed-core:9.0.33')
    implementation('org.aspectj:aspectjrt:1.9.5')
 }

请帮助我们理解这个问题


共 (1) 个答案

  1. # 1 楼答案

    添加了一些新功能,也删除了gradle5X中的一些功能,因此,请再次阅读文档并尝试添加以下依赖项,这些依赖项可能对您的API有所帮助

    dependencies {
    // Ensure you use the Groovy 3.x variant
    testImplementation('org.spockframework:spock-core:2.0-groovy-3.0') {
        exclude group: 'org.codehaus.groovy'
    }
    testImplementation('org.junit.jupiter:junit-jupiter-api')
    

    }

    // Spock 2 is based on JUnit Platform and needs to be enabled explicitly.
    tasks.withType(Test).configureEach {
        useJUnitPlatform()
    }
    

    另外,再看一次这篇文章,以获得更详细的https://docs.gradle.org/current/userguide/upgrading_version_6.html