Loading...

文章背景图

SOFABoot:蚂蚁金融级 Spring Boot 开发框架引入与使用指南

2026-04-24
0
- 字
- 分钟

SOFABoot:蚂蚁金融级 Spring Boot 开发框架引入与使用指南

一、项目官方信息

项目 信息
GitHub 仓库 sofastack/sofa-boot
中文文档 README_ZH
开源协议 Apache-2.0
主要语言 Java
Star 数 约 1.4k

SOFABoot 是蚂蚁金服开源的基于 Spring Boot 的 Java 开发框架,在 Spring Boot 基础上提供应用就绪检查、Spring 上下文隔离、类隔离、日志空间分离等增强,可无缝接入 SOFAStack 中间件。

SOFABoot 仓库封面

二、官方图片

上图为 SOFABoot 仓库在 GitHub 上的社交预览图。

三、环境要求

  • JDK 8+;
  • Maven 3.6+;
  • Spring Boot 2.x/3.x。

四、引入步骤

1. 引入依赖

<dependency>
    <groupId>com.alipay.sofa</groupId>
    <artifactId>sofaboot-dependencies</artifactId>
    <version>最新版本</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>

2. 启动类

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

3. 启用 SOFA 模块

<dependency>
    <groupId>com.alipay.sofa</groupId>
    <artifactId>runtime-sofa-boot-starter</artifactId>
</dependency>

4. 使用类隔离(可选)

@SofaModule
public class MyModule {}

五、使用方法

  • 就绪检查:区分 liveness 与 readiness;
  • 上下文隔离:模块化开发;
  • 类隔离:避免类冲突;
  • 日志隔离:各 SDK 日志空间分离;
  • 中间件集成:Seata、SOFARPC、SOFARegistry。

六、常见问题 FAQ

  1. SOFABoot 是什么? 基于 Spring Boot 的金融级增强框架。

  2. 和 Spring Boot 兼容吗? 完全兼容,额外增强。

  3. 有什么核心增强? 就绪检查、上下文/类隔离、日志分离。

  4. 适合什么场景? 大型微服务、模块化、金融级应用。

  5. 怎么启用类隔离? 引入 runtime-sofa-boot-starter。

  6. 协议是什么? Apache-2.0。

七、跳转链接

评论交流

文章目录