gpt4 book ai didi

gradle - 导入协程-常见会导致错误 “Cannot inline bytecode build with JVM target 1.8 into…”。即使使用明确指定的jvmTarget

转载 作者:行者123 更新时间:2023-12-03 05:07:20 24 4
gpt4 key购买 nike

我正在尝试在 Spring 项目中导入Kotlin协程。

我的build.gradle文件中包含以下几行:

compileKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = '1.8'
}
}

compileTestKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = '1.8'
}
}

但是无论如何,当我使用 implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-common:1.1.1'导入通用程序时,我得到了错误: Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option
如果删除 implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-common:1.1.1',则项目构建良好。

如何导入Kotlin协程?

附言我试过了
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
apiVersion = "1.3"
languageVersion = "1.3"
jvmTarget = "1.8"
}
}

完整的 build.gradle文件:
buildscript {
repositories {
mavenCentral()
}

dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")
classpath("org.jetbrains.kotlin:kotlin-noarg:1.3.20")
classpath("org.jetbrains.kotlin:kotlin-allopen:1.3.20")
}
}

plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'org.jetbrains.kotlin.jvm' version '1.3.20'
id 'org.jetbrains.kotlin.plugin.spring' version '1.3.20'
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'kotlin-jpa'

allOpen {
annotation("javax.persistence.Entity")
annotation("javax.persistence.MappedSuperclass")
annotation("javax.persistence.Embeddable")
}

group = 'com.liberaid'
version = '0.0.1'
sourceCompatibility = '1.8'

repositories {
mavenCentral()
maven { url "https://dl.bintray.com/rookies/maven" }
}

dependencies {
def withoutX = {
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
exclude group: 'org.slf4j', module: 'slf4j-jdk14'
exclude group: 'ch.qos.logback', module: 'logback-classic'
}

implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
implementation 'commons-net:commons-net:3.6'
implementation 'net.lingala.zip4j:zip4j:1.3.2'
implementation 'org.apache.pdfbox:pdfbox:2.0.1'

implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'mysql:mysql-connector-java:+'

/* Json parsers */
implementation 'org.json:json:+'
implementation 'com.google.code.gson:gson:+'

/* HTML parser */
implementation 'org.jsoup:jsoup:1.11.3'

/* GROBID - citation parser */
implementation 'org.grobid:grobid-core:0.5.4', withoutX
implementation 'org.grobid:grobid-trainer:0.5.4', withoutX

/* Kotlin coroutines */
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-common:1.1.1'

runtimeOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

compileKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = '1.8'
}
}

compileTestKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = '1.8'
}
}

最佳答案

依赖性org.jetbrains.kotlinx:kotlinx-coroutines-common:1.1.1错误。

请改用org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.1.1

关于gradle - 导入协程-常见会导致错误 “Cannot inline bytecode build with JVM target 1.8 into…”。即使使用明确指定的jvmTarget,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55319579/

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