You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

未引入Spring Web的Spring Boot项目是否需手动添加Jackson依赖?

Spring 与 Jackson 依赖关系及你的项目解决方案

先理清依赖来源

  • Spring 核心框架:本身不自带Jackson依赖,只有Spring Web模块(包括spring-web、spring-webmvc)会引入Jackson相关组件,因为Web场景需要JSON序列化/反序列化能力。
  • Spring Boot:Boot的starter体系中,spring-boot-starter-web会自动包含spring-boot-starter-json(这个starter封装了Jackson的核心依赖)。但如果你的项目没有引入Web starter,Boot不会自动帮你引入Jackson。

你的项目解决方案

因为你用的是未引入Spring Web依赖的Spring Boot项目,所以确实需要手动添加Jackson依赖,具体配置如下:

Gradle 配置(build.gradle)

dependencies {
    // 推荐用Spring Boot的starter,自动适配版本
    implementation 'org.springframework.boot:spring-boot-starter-json'
    // 也可以直接引入Jackson核心包(需自行维护版本)
    // implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
}

Maven 配置(pom.xml)

<!-- 推荐用Spring Boot starter,自动管理版本 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-json</artifactId>
</dependency>

<!-- 或者直接引入Jackson核心包 -->
<!--
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.15.2</version>
</dependency>
-->

注意:优先使用spring-boot-starter-json,它会自动适配当前Spring Boot版本对应的Jackson版本,避免版本冲突问题。

内容的提问来源于stack exchange,提问作者Sehee Lee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 04:04:49