Convert Figma logo to code with AI

sofastack logosofa-boot

SOFABoot is a framework that enhances Spring Boot and fully compatible with it, provides readiness check, class isolation, etc.

4,944
1,260
4,944
10

Top Related Projects

Spring Boot

13,702

Quarkus: Supersonic Subatomic Java.

Micronaut Application Framework

40,439

The java implementation of Apache Dubbo. An RPC and microservice framework.

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.

ServiceComb Java Chassis is a Software Development Kit (SDK) for rapid development of microservices in Java, providing service registration, service discovery, dynamic routing, and service management features

Quick Overview

SOFABoot is an enhanced Java development framework based on Spring Boot, created by Ant Financial. It provides enterprise-level features such as modular development, class isolation, and enhanced Spring context management, making it suitable for building large-scale and complex applications.

Pros

  • Modular architecture for better code organization and maintainability
  • Enhanced class isolation to prevent dependency conflicts
  • Improved Spring context management for faster startup times
  • Seamless integration with other SOFA (Scalable Open Financial Architecture) components

Cons

  • Steeper learning curve compared to vanilla Spring Boot
  • Limited community support compared to more mainstream frameworks
  • Potential overhead for smaller projects that don't require enterprise-level features
  • Dependency on Ant Financial's ecosystem may limit flexibility in some cases

Code Examples

  1. Creating a SOFABoot application:
@SpringBootApplication
@EnableSofaBootContext
public class SofaBootApplication {
    public static void main(String[] args) {
        SpringApplication.run(SofaBootApplication.class, args);
    }
}
  1. Defining a SOFA module:
@SofaModule(moduleName = "com.example.module", moduleVersion = "1.0.0")
public class ExampleModule {
    // Module implementation
}
  1. Using SOFA's dependency injection:
@SofaReference
private ExampleService exampleService;

@SofaService
public class ExampleServiceImpl implements ExampleService {
    // Service implementation
}

Getting Started

  1. Add SOFABoot dependency to your pom.xml:
<dependency>
    <groupId>com.alipay.sofa</groupId>
    <artifactId>sofa-boot-starter</artifactId>
    <version>3.11.0</version>
</dependency>
  1. Create a SOFABoot application class:
@SpringBootApplication
@EnableSofaBootContext
public class MyApplication {
    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }
}
  1. Run the application using Maven:
mvn spring-boot:run

Competitor Comparisons

Spring Boot

Pros of Spring Boot

  • Larger community and ecosystem, resulting in more resources, plugins, and third-party integrations
  • More comprehensive documentation and extensive tutorials available
  • Wider adoption in enterprise environments, leading to better job market opportunities

Cons of Spring Boot

  • Steeper learning curve for beginners due to its extensive feature set
  • Can be considered "heavier" with more dependencies, potentially leading to larger application sizes
  • Less focus on specific microservices scenarios compared to SOFA Boot

Code Comparison

Spring Boot:

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

SOFA Boot:

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

The main difference in the code is the addition of the @EnableSofaBootContext annotation in SOFA Boot, which enables SOFA-specific features. Both frameworks use Spring Boot's core functionality, but SOFA Boot extends it with additional capabilities tailored for Alipay's microservices architecture.

13,702

Quarkus: Supersonic Subatomic Java.

Pros of Quarkus

  • Faster startup time and lower memory footprint due to its container-first approach
  • Extensive support for Kubernetes and cloud-native development
  • Live coding feature for rapid development and testing

Cons of Quarkus

  • Steeper learning curve for developers new to reactive programming
  • Smaller ecosystem compared to more established frameworks
  • Limited support for non-JVM languages

Code Comparison

Quarkus:

@Path("/hello")
public class GreetingResource {
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return "Hello from Quarkus";
    }
}

SOFA-Boot:

@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String hello() {
        return "Hello from SOFA-Boot";
    }
}

Both frameworks provide simple ways to create RESTful endpoints, but Quarkus uses JAX-RS annotations while SOFA-Boot uses Spring-style annotations. Quarkus's approach is more aligned with Java EE standards, while SOFA-Boot follows the Spring Boot convention.

SOFA-Boot offers a more familiar programming model for Spring developers, while Quarkus introduces new concepts that may require additional learning. However, Quarkus's design choices lead to improved performance and resource utilization, especially in containerized environments.

Micronaut Application Framework

Pros of Micronaut Core

  • Faster startup time and lower memory footprint due to compile-time dependency injection
  • Built-in support for serverless and cloud-native applications
  • Extensive support for reactive programming and non-blocking I/O

Cons of Micronaut Core

  • Steeper learning curve for developers familiar with traditional Spring-based frameworks
  • Smaller ecosystem and community compared to more established frameworks
  • Limited support for certain enterprise features out-of-the-box

Code Comparison

Micronaut Core:

@Controller("/hello")
public class HelloController {
    @Get("/{name}")
    public String hello(String name) {
        return "Hello, " + name + "!";
    }
}

SOFA Boot:

@RestController
public class HelloController {
    @RequestMapping("/hello/{name}")
    public String hello(@PathVariable String name) {
        return "Hello, " + name + "!";
    }
}

Both frameworks offer similar syntax for creating RESTful endpoints, but Micronaut uses its own annotations while SOFA Boot leverages Spring annotations. Micronaut's approach leads to faster startup times and reduced memory usage due to compile-time processing, while SOFA Boot benefits from the familiarity and extensive ecosystem of Spring-based applications.

40,439

The java implementation of Apache Dubbo. An RPC and microservice framework.

Pros of Dubbo

  • More mature and widely adopted in the industry
  • Extensive documentation and community support
  • Supports multiple protocols (e.g., RPC, REST) and serialization formats

Cons of Dubbo

  • Steeper learning curve for beginners
  • Heavier framework with more dependencies
  • Less flexibility in customizing core components

Code Comparison

SOFA-Boot example:

@SofaService
public class HelloServiceImpl implements HelloService {
    public String sayHello(String name) {
        return "Hello, " + name + "!";
    }
}

Dubbo example:

@Service
public class HelloServiceImpl implements HelloService {
    public String sayHello(String name) {
        return "Hello, " + name + "!";
    }
}

Both frameworks use annotations to define services, but SOFA-Boot uses @SofaService while Dubbo uses @Service. The implementation is similar, showcasing the ease of use for both frameworks in creating simple services.

SOFA-Boot focuses on providing a modular, extensible framework for building enterprise applications, while Dubbo emphasizes high-performance RPC communication. SOFA-Boot offers more integrated components for building microservices, whereas Dubbo excels in service discovery and load balancing for distributed systems.

Spring Cloud Alibaba provides a one-stop solution for application development for the distributed solutions of Alibaba middleware.

Pros of spring-cloud-alibaba

  • More comprehensive cloud-native solution, integrating with Alibaba Cloud services
  • Larger community and more frequent updates
  • Better documentation and examples for various use cases

Cons of spring-cloud-alibaba

  • Steeper learning curve due to more components and integrations
  • Potential vendor lock-in with Alibaba Cloud services
  • Heavier footprint compared to sofa-boot

Code Comparison

spring-cloud-alibaba:

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

sofa-boot:

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

Both frameworks extend Spring Boot, but spring-cloud-alibaba focuses on cloud-native features and Alibaba Cloud integration, while sofa-boot emphasizes modularity and lightweight design. spring-cloud-alibaba offers a broader range of cloud services and components, making it suitable for complex distributed systems. sofa-boot, on the other hand, provides a more streamlined approach with its modular architecture, making it easier to adopt for simpler applications or gradual migration scenarios.

ServiceComb Java Chassis is a Software Development Kit (SDK) for rapid development of microservices in Java, providing service registration, service discovery, dynamic routing, and service management features

Pros of ServiceComb Java Chassis

  • More comprehensive microservices framework with built-in service registry, discovery, and governance features
  • Better support for multiple programming models (RPC, REST, etc.) and protocols (HTTP, gRPC, etc.)
  • Active Apache project with broader community support and contributions

Cons of ServiceComb Java Chassis

  • Steeper learning curve due to more complex architecture and concepts
  • Less seamless integration with Spring ecosystem compared to SOFA Boot
  • Potentially heavier runtime footprint for simpler applications

Code Comparison

ServiceComb Java Chassis:

@RpcSchema(schemaId = "helloService")
public class HelloServiceImpl implements HelloService {
    @Override
    public String sayHello(String name) {
        return "Hello " + name;
    }
}

SOFA Boot:

@SofaService
public class HelloServiceImpl implements HelloService {
    @Override
    public String sayHello(String name) {
        return "Hello " + name;
    }
}

Both frameworks use annotations to define services, but ServiceComb Java Chassis uses @RpcSchema with a schema ID, while SOFA Boot uses @SofaService. The implementation itself is similar, showcasing the different approaches to service definition in each framework.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

SOFABoot

Build And Test Coverage Status license Average time to resolve an issue Percentage of issues still open maven

中文版本

SOFABoot is an open source Java development framework based on Spring Boot.

Varieties of enhancements such as application readiness check, Spring context isolation, class isolation, log space separation, etc. are provided out of box. In addition, SOFABoot accommodates SOFAStack middlewares more comfortably and seamlessly for developers coming from Spring Boot world.

Background

Spring Boot makes it easy to create stand-alone, production-grade Spring-based applications which "just run". However, some domain-specific issues remain open:

  • Spring Boot provides health indicators to reveal the liveness of application but not readiness (aka the capability of servicing requests).
  • No built-in class isolation scheme to support finer modular applications.
  • Log configurations of all SDKs used by application are repeatedly arranged.

To address the above issues while maintaining the advantages of Spring Boot, Ant Group develops the SOFABoot based on Spring Boot and make it open source. In SOFABoot, SOFAStack middleware SDKs are packaged as self-contained "starters" to provide the corresponding facet or functionality dependencies.

Quick Start

Please refer to SOFAStack Documentation for SOFABoot quick start guide.

Demos

Some SOFABoot demo projects to get your hands dirty:

Functionality

To supplement the abilities of deploying large-scale microservices in production environment for Spring Boot, SOFABoot offers following enhancements:

Readiness Check

If request traffic reaches service instance before it is fully initialized, requests are subject to timeout or exceptions. While Spring Boot health indicators are practical real-time exposure of application health, it doesn't help determine when services are available. Therefore, readiness check is an indispensable part of deployment automation in production environment and SOFABoot provides the readiness check for application out of box. For reliable application startup, all SOFAStack middleware services won't reveal themselves (e.g., RPC services publishing to Service Registry) until readiness check passes.

Platform PaaS can also make use of the readiness check result via URL http://localhost:8080/actuator/readiness to control gracefully external traffic originating such as gateway, load balancer, etc.

Class Isolation

Aimed to solve class or dependency conflicts, SOFAArk is created. Compared with unwieldy OSGi class isolation implementation, SOFAArk is a light-weight scheme and focuses on the point of class loading between application and middleware modules. Also, it is easy to make a third party SDK into SOFAArk module because the high extensibility of SOFAArk.

See further on SOFAArk documentation.

Spring Context Isolation

Two common forms of modularization are popular in Java world:

  1. Modularization based on code organization: different functional codes are organized under separate Java projects and packaged into different JARs. All Java classes are loaded by same classloader when running.
  2. Modularization based on classloader: each module has its own classloader and classpath between different modules differs.

SOFABoot supplies a third option with degree of modularity between above two, which is built upon Spring Context. Different modules owns by itself a distinct Spring Context and all contexts forms a simple dependency tree. Bean resolution of dependency injection happens in the path up to the tree root. It is obvious that bean and configuration conflicts are avoided between different modules, communication between teams during enterprise-level multi-module development is reduced effectively.

More details about SOFABoot modularization are introduced in this article.

Unified Logging

In Spring Boot, the responsibility of log configurations is left to users: all the users of a certain SDK need to configure for its logging, but the configurations are basically the same in most cases. In order to save the repeated configuration, SOFABoot utilizes the sofa-common-tools to provide for each SDKs basic log configurations. Users don't need to worry about SDk logging anymore. Besides, every SDK has a different logging directory to separate it from application logs to assist handy monitoring based on logging.

Built-in SOFAStack Middlewares

Based on the auto-configuring and dependencies descriptor (aka starter) in Spring Boot, SOFABoot offers easy-to-use programming interface for all SOFAStack middlewares. All of them are packaged as self-contained "starters" to provide the corresponding facet dependencies and are independently pluggable.

Contribution

We love contributions! Before taking any further steps, please take a look at Contributing to SOFABoot.

SOFABoot is compiled under JDK 17 currently and needs Apache Maven 3.5.4 or higher version.

Community

See our community materials.

Contact Us

See Community contact way

Acknowledgements

The first version of SOFA is created by Felix(阿玺), lots of thanks are given to Felix for laying a solid foundation for SOFA. It is also very grateful to the people who have contributed codes in the history of SOFA.

License

Ant Group SOFABoot is distributed under the Apache License, version 2.0. The licenses of third parity dependencies of SOFABoot are explained here.

Known Users

The SOFABoot users (the names are in no particular order). Please leave a comment here to tell us your scenario to make SOFABoot better.

蚂蚁集团 网商银行 恒生电子 数立信息 Paytm 天弘基金 中国人保 信美相互 南京银行 民生银行 重庆农商行 中信证券 富滇银行 挖财 拍拍贷 OPPO金融 运满满 译筑科技 杭州米雅信息科技 邦道科技 申通快递 深圳大头兄弟文化 烽火科技 亚信科技 成都云智天下科技 上海溢米辅导 态赋科技 风一科技 武汉易企盈 极致医疗 京东 小象生鲜 北京云族佳 欣亿云网 山东网聪 深圳市诺安赛威 上扬软件 长沙点三 网易云音乐 虎牙直播 中国移动 无纸科技 黄金钱包 独木桥网络 wueasy 北京攸乐科技 易宝支付 威马汽车 亿通国际 新华三 klilalagroup