gpt4 book ai didi

java - Gradle 在使用 bootRun 生成时运行时找不到符号 isEmpty

转载 作者:行者123 更新时间:2023-12-01 22:03:28 24 4
gpt4 key购买 nike

我正在使用 Gradle 编译项目,当我使用 bootRun 运行它时,它输出以下错误:找不到符号 isEmpty,有很多,我知道这是 java 版本的问题,但我不知道如何纠正它们,很遗憾他们不允许短版本发布。

这是我的 gradle 配置:

    buildscript {
ext.kotlin_version = '1.3.50'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'org.springframework.boot' version '2.2.0.M5'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
id 'net.ltgt.apt' version '0.20'
}

apply plugin: 'net.ltgt.apt-idea'
apply plugin: 'kotlin'
apply plugin: 'net.ltgt.apt-eclipse'

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

configurations {
mapstruct
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}

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

ext {
set('springCloudVersion', "Hoxton.M2")
generatedMapperSourcesDir = "${buildDir}/generated-src/mapstruct/main"
}

sourceSets.main {
ext.originalJavaSrcDirs = java.srcDirs
java.srcDir "${generatedMapperSourcesDir}"
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-batch'
implementation 'org.springframework.boot:spring-boot-starter-cloud-connectors'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation('com.github.binarywang:wx-java-miniapp-spring-boot-starter:3.5.0')
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-security")
compile('org.modelmapper:modelmapper:2.3.5')
implementation 'org.springframework.cloud:spring-cloud-starter'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}


implementation "org.mapstruct:mapstruct"
annotationProcessor "org.mapstruct:mapstruct-processor"

compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
compile 'org.mapstruct:mapstruct:1.3.0.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.3.0.Final'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile 'com.qiniu:qiniu-java-sdk:7.2.+'
compile 'com.alibaba:fastjson:1.2.61'
compile group: 'org.ocpsoft.prettytime', name: 'prettytime', version: '4.0.2.Final'
compile group: 'org.ocpsoft.prettytime', name: 'prettytime-nlp', version: '4.0.2.Final'
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

test {
useJUnitPlatform()
}



task generateMainMapperClasses(type: JavaCompile) {
ext.aptDumpDir = file( "${buildDir}/tmp/apt/mapstruct" )
destinationDir = ext.aptDumpDir

classpath = compileJava.classpath + configurations.mapstruct
source = sourceSets.main.originalJavaSrcDirs
ext.sourceDestDir = file ( "$generatedMapperSourcesDir" )

options.define(
compilerArgs: [
"-nowarn",
"-proc:only",
"-encoding", "UTF-8",
"-processor", "org.mapstruct.ap.MappingProcessor",
"-s", ext.sourceDestDir.absolutePath,
"-source", rootProject.sourceCompatibility,
"-target", rootProject.sourceCompatibility,
]
);

inputs.dir source
outputs.dir generatedMapperSourcesDir;
doFirst {
ext.sourceDestDir.mkdirs()
}
doLast {
ext.aptDumpDir.delete()
}
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

//compileJava.dependsOn generateMainMapperClasses

最佳答案

是的。 JDK版本,升级JDK版本解决问题。并使用 sourceCompatibility = '13' 更新文件

关于java - Gradle 在使用 bootRun 生成时运行时找不到符号 isEmpty,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58705780/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com