SpringBoot 2.5.0 对于 Jackson Kotlin 类 支持请添加 "com.fasterxml.jackson.module: jackson-module-kotlin" 到类路径

SpringBoot 2.5.0 For Jackson Kotlin classes support please add "com.fasterxml.jackson.module: jackson-module-kotlin" to the classpath

SpringBoot 2.5.1 现已修复此问题

关于我收到的警告的小问题。

SpringBoot 2.5.0 发布后,我只是做了一个版本从 2.4.x 升级到 2.5.0,没有任何代码更改。

突然,在应用程序启动时,我得到

kground-preinit] o.s.h.c.j.Jackson2ObjectMapperBuilder: For Jackson Kotlin classes support please add "com.fasterxml.jackson.module:jackson-module-kotlin" to the classpath

问题是,我的 Springboot 不是 Kotlin 应用程序,而是 Java 应用程序。

它没有 Kotlin。

此外,我什至没有进行任何显式 JSON 解析。

请问如何禁用,请解决此警告?

似乎有解决办法here。这个想法是为 Jackson2ObjectMapperBuilderCustomizer 提供额外的配置。糟透了,需要更改代码,但你已经做到了。

这发生在构建器检查类路径中是否存在 kotlin-runtime 时,方法很简单:

if (KotlinDetector.isKotlinPresent())

因此,您应该只从项目依赖关系树中删除 kotlin-runtime。例如,org.springframework.boot:spring-boot-starter-security 具有对 org.jetbrains.kotlin 的传递依赖性。 简单排除为:

exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'

尽情享受吧。

编辑:只需升级到 Spring Boot 2.5.1 即可解决此问题。


下面是旧答案:

我现在设法通过向我的 spring-boot-starter-security 依赖项添加排除项来解决此问题,该依赖项显然定义了此 Kotlin 依赖项。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-security</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-reflect</artifactId>
        </exclusion>
    </exclusions>
</dependency>