java - 使用 bootRun generate 运行时 Gradle 找不到符号 isEmpty
问题描述
我正在使用 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' 更新文件
推荐阅读
- regex - 为什么 Google 表格中的 regexreplace 和 regexextract 工作方式不同?
- linux - “NameUser”当前被进程使用
- python - 在 Windows 上卸载 distutils 安装的项目?
- python - 如何在 hsv 中选择好的上限和下限?
- amazon-web-services - AWS Lambda (RequestStreamLambda) IOStream 问题
- ios - 为什么每次模拟器运行后都会出现 SIGTERM 错误?
- ios - 没有这样的模块 PanModal - Xcode ios app swift
- html - 如何使用 flexbox 在图像上正确放置文本
- laravel - 试图获得更短的链接 laravel
- javascript - 如何使用 nodejs 中的 express 呈现带有侧 js 文件的 HTML 文件?