Gradle和Jackson相依性

mcdcgff0  于 2023-01-26  发布在  其他
关注(0)|答案(1)|浏览(111)

我是Gradle和Kotlin的新手,正在开始构建我的第一个应用。我希望使用Jackson模块来序列化Map对象。我的Gradle文件如下所示

import org.jsonschema2pojo.InclusionLevel

buildscript {
    ext.js2p_version = "1.0.0"

    repositories {
        jcenter()
    }
    dependencies {
        classpath("org.jsonschema2pojo:jsonschema2pojo-gradle-plugin:${js2p_version}")
    }

}

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.4.10'
}

group = "me"
version = "1.0-SNAPSHOT"
repositories {
    jcenter()
}

apply plugin: "java"
apply plugin: "jsonschema2pojo"

jsonSchema2Pojo {
    source = files("src/main/resources/config.json")
    targetPackage = 'com.config'
    removeOldOutput = true
    classNameSuffix = 'Desc'
    inclusionLevel = InclusionLevel.ALWAYS
    includeJsr303Annotations = true
    useBigDecimals = true
    includeAdditionalProperties = true
}

dependencies {
    //implementation platform("com.fasterxml.jackson:jackson-bom:2.10.1")
    implementation platform("com.fasterxml.jackson.module:jackson-module-kotlin:2.11.0")
    //implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.11.+"
    /**
     * This dependency does not need to be 100% in-sync with the main project.
     */
    compileOnly 'com.fasterxml.jackson.core:jackson-annotations'
    compileOnly 'com.fasterxml.jackson.core:jackson-databind'
    compileOnly 'javax.validation:validation-api:2.0.1.Final'
    testImplementation 'org.jetbrains.kotlin:kotlin-test-junit'

}

compileKotlin {
    kotlinOptions.jvmTarget = '1.8'
}

然而当我试图构建它时,我在info.kt类(位于主目录下)中得到一个错误

谢谢

cnh2zyt3

cnh2zyt31#

KotlinModule是您在Gradle文件中注解掉的com.fasterxml.jackson.module:jackson-module-kotlin的一部分。
取消注解,导入应该开始工作。

相关问题