D
Duelist-Fiora 发布的最新帖子
-
RE: 如何将官方文档中的hello world项目打成jar包
@RayyyWW 在 如何将官方文档中的hello world项目打成jar包 中说:
build 而不是jar
改为使用build之后出现了
Could not resolve net.mamoe:mirai-core-api
的异常, 还是没有打包成功
完整的错误日志
Execution failed for task ':bootJarMainClassName'. > Could not resolve all files for configuration ':productionRuntimeClasspath'. > Could not resolve net.mamoe:mirai-core-api:2.6.2. Required by: project : > 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.6.2: - androidRuntimeElements-published - commonRuntimeElements-published - jvmRuntimeElements-published All of them match the consumer attributes: - Variant 'androidRuntimeElements-published' capability net.mamoe:mirai-core-api:2.6.2 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 'androidJvm' but the consumer didn't ask for it - Variant 'commonRuntimeElements-published' capability net.mamoe:mirai-core-api:2.6.2 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.6.2 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 'androidApiElements-published' capability net.mamoe:mirai-core-api:2.6.2 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 'commonApiElements-published' capability net.mamoe:mirai-core-api:2.6.2 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.6.2: - 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.6.2 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.6.2: - 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:2.6.2. Required by: project : > 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:2.6.2: - androidRuntimeElements-published - commonRuntimeElements-published - jvmRuntimeElements-published All of them match the consumer attributes: - Variant 'androidRuntimeElements-published' capability net.mamoe:mirai-core:2.6.2 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 'androidJvm' but the consumer didn't ask for it - Variant 'commonRuntimeElements-published' capability net.mamoe:mirai-core:2.6.2 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:2.6.2 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 'androidApiElements-published' capability net.mamoe:mirai-core:2.6.2 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 'commonApiElements-published' capability net.mamoe:mirai-core:2.6.2 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:2.6.2: - 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:2.6.2 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:2.6.2: - 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)
-
如何将官方文档中的hello world项目打成jar包
问题描述
我在文档中的hello world 项目 (https://github.com/project-mirai/mirai-hello-world ) 的基础上写了一个spring boot 项目, 想要将其打成jar包放到服务器运行
我没有gradle的使用经验, 初步搜索之后了解到可以直接使用IDEA的gradle功能进行打包, 但是没有成功
gradle打包日志
6:25:57 下午: Executing task 'jar'... > Task :compileKotlin > Task :compileJava > Task :processResources UP-TO-DATE > Task :classes > Task :inspectClassesForKotlinIC > Task :jar SKIPPED BUILD SUCCESSFUL in 1s 4 actionable tasks: 3 executed, 1 up-to-date 6:25:59 下午: Task execution finished 'jar'.
我使用的IDEA功能入口
我的build.gradle.kts文件内容
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile plugins { java kotlin("jvm") version "1.4.32" id("org.springframework.boot") version "2.4.4" id("io.spring.dependency-management") version "1.0.11.RELEASE" } group = "org.example" version = "0.1.0" repositories { mavenCentral() } tasks.withType(KotlinJvmCompile::class.java) { kotlinOptions.jvmTarget = "1.8" } dependencies { api("net.mamoe:mirai-core-api:${properties["version.mirai"]}") runtimeOnly("net.mamoe:mirai-core:${properties["version.mirai"]}") implementation("org.springframework.boot:spring-boot-starter") implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-data-redis") implementation("mysql:mysql-connector-java:8.0.28") implementation("com.baomidou:mybatis-plus-boot-starter:3.5.1") compileOnly("org.projectlombok:lombok:1.18.24") annotationProcessor("org.projectlombok:lombok:1.18.24") implementation("cn.hutool:hutool-all:5.7.22") implementation("com.github.xiaoymin:knife4j-spring-boot-starter:3.0.3") }