simple-robot / simpler-robot

Simple Robot,一个bot风格的Kotlin多平台事件调度框架,异步高效、Java友好!/ A Bot-style Kotlin Multiplatform event scheduling framework, asynchronous and high-performance, java-friendly! 🐱😼😻😸
https://simbot.forte.love
GNU Lesser General Public License v3.0
520 stars 43 forks source link

[QU.] mirai版本更新后利用gradle打包失败 #73

Closed ForteScarlet closed 3 years ago

ForteScarlet commented 3 years ago

mirai版本更新后利用gradle打包失败

liuc-c commented 3 years ago

哭了,2.4.0 版本的也下载不下来,尝试 mirai #746 中的方法也没搞定,VPN也没啥问题 提示信息 Could not resolve net.mamoe:mirai-core-api:2.4.0.

ForteScarlet commented 3 years ago

话说有添加

mavenCentral()
或 
jcenter()

liuc-c commented 3 years ago

我的gradle是这样的

repositories {
    jcenter()
    maven { url 'https://maven.aliyun.com/repository/public' }
    maven { url 'https://maven.aliyun.com/repository/google' }
    mavenLocal()
    mavenCentral()
}
ForteScarlet commented 3 years ago

只留下

mavenCentral()
jcenter()

试试?mirai说2.4.0之后会同时发布到jcenter和maven

liuc-c commented 3 years ago

只留下这俩也不行

ForteScarlet commented 3 years ago

换个网试试,比如手机热点

liuc-c commented 3 years ago

刚刚换了试了,放弃了qaq

ForteScarlet commented 3 years ago

下下策,你可以试试换成maven

ForteScarlet commented 3 years ago

或者先用着旧版本之类的

liuc-c commented 3 years ago

好的,谢谢啦

liuc-c commented 3 years ago

我折腾了一下,现在用2.0.3版本里的2.4.0的mirai,可以用bootRun运行起来了,spring boot项目是可以运行,但是用gradle打包就报错了,和https://github.com/mamoe/mirai/discussions/746#discussion-82760 里报错一样,跟着他说的尝试一遍过后还是同 样的错。大佬给点建议。

现在我的build.gradle

buildscript {
    repositories {
        jcenter()
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        classpath 'gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.20.0'
        classpath "org.springframework.boot:spring-boot-gradle-plugin:2.3.1.RELEASE"
    }
}
plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.4.30-M1'
    id "org.jetbrains.kotlin.plugin.spring" version "1.4.30-M1"
    id 'org.springframework.boot' version '2.4.0'
    id 'io.spring.dependency-management' version '1.0.10.RELEASE'
    id 'java'
}
repositories {
    mavenCentral()
    jcenter()
}
group = 'com.choool'
version = '0.0.1-SNAPSHOT'

// docker插件
apply plugin: 'com.palantir.docker'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.12.0-rc2'
    compile group: 'cn.xsshome', name: 'taip', version: '4.3.5'
    compile group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.10.0-RC1'
    implementation 'love.forte.simple-robot:component-mirai-spring-boot-starter:2.0.3'
    compile group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version: '2.1.4'
    compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.23'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: '2.4.2'
    compile group: 'com.github.pagehelper', name: 'pagehelper-spring-boot-starter', version: '1.3.0'
}
test {
    useJUnitPlatform()
}
bootJar {
    project.group = 'com.choool'
}
报错

12:00:18:执行任务  'build' ...

> Task :compileKotlin UP-TO-DATE
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :bootJarMainClassName FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.3/userguide/command_line_interface.html#sec:command_line_warnings
4 actionable tasks: 1 executed, 3 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bootJarMainClassName'.
> Could not resolve all files for configuration ':productionRuntimeClasspath'.
   > Could not resolve net.mamoe:mirai-core-api:2.4.0.
     Required by:
         project : > love.forte.simple-robot:component-mirai-spring-boot-starter:2.0.3 > love.forte.simple-robot:component-mirai:2.0.3 > net.mamoe:mirai-core-jvm:2.4.0
      > The consumer was configured to find a runtime of a component, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of net.mamoe:mirai-core-api:2.4.0:
          - commonRuntimeElements-published
          - jvmRuntimeElements-published
        All of them match the consumer attributes:
          - Variant 'commonRuntimeElements-published' capability net.mamoe:mirai-core-api:2.4.0 declares a runtime of a component, packaged as a jar:
              - Unmatched attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'common' but the consumer didn't ask for it
          - Variant 'jvmRuntimeElements-published' capability net.mamoe:mirai-core-api:2.4.0 declares a runtime of a component, packaged as a jar:
              - Unmatched attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but the consumer didn't ask for it
        The following variants were also considered but didn't match the requested attributes:
          - Variant 'commonApiElements-published' capability net.mamoe:mirai-core-api:2.4.0 declares a component, packaged as a jar:
              - Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
              - Other compatible attribute:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
          - Variant 'commonMainMetadataElements-published' capability net.mamoe:mirai-core-api:2.4.0:
              - Incompatible because this component declares a usage of 'kotlin-api' of a component and the consumer needed a runtime of a component
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its elements (required them packaged as a jar)
          - Variant 'jvmApiElements-published' capability net.mamoe:mirai-core-api:2.4.0 declares a component, packaged as a jar:
              - Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
              - Other compatible attribute:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
          - Variant 'metadataApiElements-published' capability net.mamoe:mirai-core-api:2.4.0:
              - Incompatible because this component declares a usage of 'kotlin-metadata' of a component and the consumer needed a runtime of a component
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its elements (required them packaged as a jar)
   > Could not resolve net.mamoe:mirai-core-utils:2.4.0.
     Required by:
         project : > love.forte.simple-robot:component-mirai-spring-boot-starter:2.0.3 > love.forte.simple-robot:component-mirai:2.0.3 > net.mamoe:mirai-core-jvm:2.4.0
      > The consumer was configured to find a runtime of a component, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of net.mamoe:mirai-core-utils:2.4.0:
          - commonRuntimeElements-published
          - jvmRuntimeElements-published
        All of them match the consumer attributes:
          - Variant 'commonRuntimeElements-published' capability net.mamoe:mirai-core-utils:2.4.0 declares a runtime of a component, packaged as a jar:
              - Unmatched attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'common' but the consumer didn't ask for it
          - Variant 'jvmRuntimeElements-published' capability net.mamoe:mirai-core-utils:2.4.0 declares a runtime of a component, packaged as a jar:
              - Unmatched attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Provides release status but the consumer didn't ask for it
                  - Provides attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but the consumer didn't ask for it
        The following variants were also considered but didn't match the requested attributes:
          - Variant 'commonApiElements-published' capability net.mamoe:mirai-core-utils:2.4.0 declares a component, packaged as a jar:
              - Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
              - Other compatible attribute:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
          - Variant 'commonMainMetadataElements-published' capability net.mamoe:mirai-core-utils:2.4.0:
              - Incompatible because this component declares a usage of 'kotlin-api' of a component and the consumer needed a runtime of a component
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its elements (required them packaged as a jar)
          - Variant 'jvmApiElements-published' capability net.mamoe:mirai-core-utils:2.4.0 declares a component, packaged as a jar:
              - Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
              - Other compatible attribute:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
          - Variant 'metadataApiElements-published' capability net.mamoe:mirai-core-utils:2.4.0:
              - Incompatible because this component declares a usage of 'kotlin-metadata' of a component and the consumer needed a runtime of a component
              - Other compatible attributes:
                  - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                  - Doesn't say anything about its elements (required them packaged as a jar)
ForteScarlet commented 3 years ago

尝试:

implementation("love.forte.simple-robot:component-mirai-spring-boot-starter:2.0.3") {
        exclude group: 'net.mamoe', module: 'mirai-core-api'
        exclude group: 'net.mamoe', module: 'mirai-core-utils'
    }

 // 其他的

且不需要额外导入mirai其他依赖

liuc-c commented 3 years ago

谢谢,但是又出现了新的错误了QAQ

    _           _           _   
    (_)         | |         | |  
 ___ _ _ __ ___ | |__   ___ | |_ 
/ __| | '_ ` _ \| '_ \ / _ \| __|
\__ \ | | | | | | |_) | (_) | |_ 
|___/_|_| |_| |_|_.__/ \___/ \__|
                    @ForteScarlet

Tips: 你知道吗?如果你读到了这条tips,那么就相当于没有读到tips。

2021-03-25 13:34:01.456  INFO 15548 --- [           main] l.f.s.s.a.SimbotAppConfiguration         : Active resources: []
2021-03-25 13:34:01.489  WARN 15548 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simbotContext' defined in love.forte.simbot.spring.autoconfigure.SimbotAppConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [love.forte.simbot.core.SimbotContext]: Factory method 'simbotApp' threw exception; nested exception is java.lang.NoClassDefFoundError: net/mamoe/mirai/utils/BotConfiguration$MiraiProtocol
2021-03-25 13:34:01.491  INFO 15548 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2021-03-25 13:34:01.499  INFO 15548 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-03-25 13:34:01.514 ERROR 15548 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'simbotContext' defined in love.forte.simbot.spring.autoconfigure.SimbotAppConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [love.forte.simbot.core.SimbotContext]: Factory method 'simbotApp' threw exception; nested exception is java.lang.NoClassDefFoundError: net/mamoe/mirai/utils/BotConfiguration$MiraiProtocol
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:656) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:636) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1179) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:571) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925) ~[spring-context-5.3.1.jar:5.3.1]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588) ~[spring-context-5.3.1.jar:5.3.1]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309) ~[spring-boot-2.4.0.jar:2.4.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298) ~[spring-boot-2.4.0.jar:2.4.0]
    at com.choool.lcbot.LcBotApplication.main(LcBotApplication.java:17) ~[main/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [love.forte.simbot.core.SimbotContext]: Factory method 'simbotApp' threw exception; nested exception is java.lang.NoClassDefFoundError: net/mamoe/mirai/utils/BotConfiguration$MiraiProtocol
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.1.jar:5.3.1]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:651) ~[spring-beans-5.3.1.jar:5.3.1]
    ... 20 common frames omitted
Caused by: java.lang.NoClassDefFoundError: net/mamoe/mirai/utils/BotConfiguration$MiraiProtocol
    at java.base/java.lang.Class.getDeclaredMethods0(Native Method) ~[na:na]
    at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166) ~[na:na]
    at java.base/java.lang.Class.getDeclaredMethods(Class.java:2309) ~[na:na]
    at love.forte.common.ioc.DependCenter.classToEmptyInstanceSupplier(DependCenter.kt:415) ~[ioc-1.0.0-ALPHA.5.jar:na]
    at love.forte.common.ioc.DependCenter.inject0(DependCenter.kt:209) ~[ioc-1.0.0-ALPHA.5.jar:na]
    at love.forte.common.ioc.DependCenter.inject(DependCenter.kt:154) ~[ioc-1.0.0-ALPHA.5.jar:na]
    at love.forte.common.ioc.DependCenter.register(DependCenter.kt:832) ~[ioc-1.0.0-ALPHA.5.jar:na]
    at love.forte.simbot.core.SimbotApp.initDependCenterWithAutoConfigures(SimbotApp.kt:229) ~[core-2.0.3.jar:na]
    at love.forte.simbot.core.SimbotApp.run$core(SimbotApp.kt:185) ~[core-2.0.3.jar:na]
    at love.forte.simbot.core.SimbotApp$Run.run(SimbotApp.kt:416) ~[core-2.0.3.jar:na]
    at love.forte.simbot.core.SimbotApp.run(SimbotApp.kt) ~[core-2.0.3.jar:na]
    at love.forte.simbot.spring.autoconfigure.SimbotAppConfiguration.simbotApp(SimbotAppConfiguration.java:87) ~[core-spring-boot-starter-2.0.3.jar:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.1.jar:5.3.1]
    ... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: net.mamoe.mirai.utils.BotConfiguration$MiraiProtocol
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
    ... 38 common frames omitted

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [love.forte.simbot.core.SimbotContext]: Factory method 'simbotApp' threw exception; nested exception is java.lang.NoClassDefFoundError: net/mamoe/mirai/utils/BotConfiguration$MiraiProtocol

Caused by: java.lang.NoClassDefFoundError: net/mamoe/mirai/utils/BotConfiguration$MiraiProtocol

Caused by: java.lang.ClassNotFoundException: net.mamoe.mirai.utils.BotConfiguration$MiraiProtocol

> Task :bootRun FAILED

Execution failed for task ':bootRun'.
> Process 'command 'D:\Program Files\JAVA\jdk-11.0.9\bin\java.exe'' finished with non-zero exit value 1
ForteScarlet commented 3 years ago

这个问题刚刚发现了,稍等,我再试试

liuc-c commented 3 years ago

好嘞,太感谢了😁

ForteScarlet commented 3 years ago

尝试:

    // kotlinx
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
    // simbot-sb-starter
    implementation("love.forte.simple-robot:component-mirai-spring-boot-starter:2.0.3") {
        exclude group: 'net.mamoe', module: 'mirai-core-api'
        exclude group: 'net.mamoe', module: 'mirai-core-utils'
    }
    // mirai-core
    implementation("net.mamoe:mirai-core-jvm:2.4.0") {
        exclude group: 'net.mamoe', module: 'mirai-core-api'
        exclude group: 'net.mamoe', module: 'mirai-core-utils'
    }
    // mirai-api
    implementation("net.mamoe:mirai-core-api-jvm:2.4.0") {
        exclude group: 'net.mamoe', module: 'mirai-core-utils'
    }
    // mirai-core-utils
    implementation("net.mamoe:mirai-core-utils-jvm:2.4.0")
liuc-c commented 3 years ago

尝试:

    // kotlinx
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2'
    // simbot-sb-starter
    implementation("love.forte.simple-robot:component-mirai-spring-boot-starter:2.0.3") {
        exclude group: 'net.mamoe', module: 'mirai-core-api'
        exclude group: 'net.mamoe', module: 'mirai-core-utils'
    }
    // mirai-core
    implementation("net.mamoe:mirai-core-jvm:2.4.0") {
        exclude group: 'net.mamoe', module: 'mirai-core-api'
        exclude group: 'net.mamoe', module: 'mirai-core-utils'
    }
    // mirai-api
    implementation("net.mamoe:mirai-core-api-jvm:2.4.0") {
        exclude group: 'net.mamoe', module: 'mirai-core-utils'
    }
    // mirai-core-utils
    implementation("net.mamoe:mirai-core-utils-jvm:2.4.0")

问题解决了,谢啦~😁

ForteScarlet commented 3 years ago