之前一直在用2.10.0的版本,今天要用新功能升级到了2.13.0-RC2,gradle build的时候报错
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
net.mamoe.mirai.internal.deps.io.ktor.client.utils.CoroutineDispatcherUtilsKt.clientDispatcher(CoroutineDispatcherUtils.kt:22)
The following method did not exist:
'kotlinx.coroutines.CoroutineDispatcher kotlinx.coroutines.CoroutineDispatcher.limitedParallelism(int)'
The calling method's class, net.mamoe.mirai.internal.deps.io.ktor.client.utils.CoroutineDispatcherUtilsKt, was loaded from the following location:
jar:file:/home/aye/bot/communismbot-2.1.0.jar!/BOOT-INF/lib/mirai-core-jvm-2.13.0-RC2.jar!/net/mamoe/mirai/internal/deps/io/ktor/client/utils/CoroutineDispatcherUtilsKt.class
The called method's class, kotlinx.coroutines.CoroutineDispatcher, is available from the following locations:
jar:file:/home/aye/bot/communismbot-2.1.0.jar!/BOOT-INF/lib/kotlinx-coroutines-core-jvm-1.5.2.jar!/kotlinx/coroutines/CoroutineDispatcher.class
The called method's class hierarchy was loaded from the following locations:
kotlinx.coroutines.CoroutineDispatcher: jar:file:/home/aye/bot/communismbot-2.1.0.jar!/BOOT-INF/lib/kotlinx-coroutines-core-jvm-1.5.2.jar!/
kotlin.coroutines.AbstractCoroutineContextElement: jar:file:/home/aye/bot/communismbot-2.1.0.jar!/BOOT-INF/lib/kotlin-stdlib-1.7.10.jar!/
Action:
Correct the classpath of your application so that it contains compatible versions of the classes net.mamoe.mirai.internal.deps.io.ktor.client.utils.CoroutineDispatcherUtilsKt and kotlinx.coroutines.CoroutineDispatcher
感觉应该是版本依赖的问题,试了半天不知道从何下手
附上build.gradle:
import java.text.SimpleDateFormat
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
classpath "gradle.plugin.ua.eshepelyuk:ManifestClasspath:1.0.0"
}
}
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.7.10'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.21'
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'org.springframework.boot' version '2.6.6'
}
compileJava {
sourceCompatibility = '1.8'
targetCompatibility = '11'
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
ext {
springVersion = '2.6.6'
miraiVersion = '2.13.0-RC2'
ktVersion = '1.6.21'
}
apply plugin: "ua.eshepelyuk.ManifestClasspath"
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'org.jetbrains.kotlin.plugin.serialization'
group 'com.aye10032'
version '2.1.0'
repositories {
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }
}
dependencies {
implementation group: 'junit', name: 'junit', version: '4.12'
implementation group: 'net.mamoe', name: 'mirai-core', version: rootProject.ext.miraiVersion
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: rootProject.ext.springVersion
// https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter
implementation group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version: '2.2.2'
// https://mvnrepository.com/artifact/org.jdom/jdom
implementation group: 'org.jdom', name: 'jdom', version: '2.0.2'
// https://mvnrepository.com/artifact/org.apache.commons/commons-lang3
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.11'
// https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.8.1'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
// https://mvnrepository.com/artifact/commons-io/commons-io
implementation group: 'commons-io', name: 'commons-io', version: '2.7'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.12'
// https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore
implementation group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.13'
// https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
implementation group: 'com.rometools', name: 'rome', version: '1.18.0'
//JavaCV相关
implementation group:'org.bytedeco', name: 'javacv-platform', version: '1.5.7'
implementation group: 'com.github.Aye10032', name: 'rtroapiutil', version: 'v1.2'
implementation(fileTree(dir: 'libs', includes: ['*.jar']))
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-quartz
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-quartz', version: rootProject.ext.springVersion
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.29'
implementation group: 'org.reflections', name: 'reflections', version: '0.10.2'
implementation group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
testCompileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
testAnnotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.4'
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
test {
useJUnitPlatform()
}
// 点这个箭头进行打包
/*jar {
configurations.compile.canBeResolved = true
configurations.implementation.canBeResolved = true
configurations.api.canBeResolved = true
//把以前的重命名归档起来
destinationDir = file("$rootDir/build")
File oldJarFile = file(destinationDir.toString() + "/" + rootProject.name + "-" + version + ".jar")
SimpleDateFormat ft = new SimpleDateFormat("MM-dd-hh-mm-ss")
File newJarFile = file(destinationDir.toString() + "/" + rootProject.name + "-" + version + "-" + ft.format(new Date()) + ".jar")
if (oldJarFile.exists()) {
oldJarFile.renameTo(newJarFile)
}
if (newJarFile.exists()) {
ant.move file: newJarFile,
todir: "${buildDir}/toArchive"
}
manifest {
//mainifest下的classpath头
def classpathPrefix = 'libs'
Set<File> files = configurations.runtimeClasspath.files
def builder = new StringBuilder()
for (def f : files) {
builder.append(classpathPrefix).append("/").append(f.getName()).append(" ")
}
attributes('Main-Class': 'com.dazo66.Main')//入口点
attributes('Class-Path': builder.toString())
}
// 将 build.gradle 打入到 jar 中, 方便查看依赖包版本
from("./") {
include 'build.gradle'
}
// 会自动把依赖复制到编译目录下的libs文件夹里面
// 如果有添加新的依赖记得复制到运行环境下的libs
copy() {
def classpathPrefix = configurations
from configurations.compile.collect { it }
into "$buildDir/libs"
}
}*/