跪拜 Guibai
← Back to the summary

Solon, the Chinese-Made Java Framework That Claims 10x Faster Startup Than SpringBoot

Follow my public account: 【编程朝花夕拾】 to get first-release content.

01 Introduction

SpringBoot has taken over half of Java development by leveraging the Spring ecosystem. During interviews, you might often encounter questions like "Why is SpringBoot slow to start?" or "How to improve SpringBoot concurrency?". Being asked these questions implies that such problems exist.

Today I discovered a domestically developed open-source framework, touted as a new-generation Java enterprise application development framework, known for being fast, compact, and concise: Solon.

02 Brief Introduction

The Solon framework is developed and open-sourced by Hangzhou Wuer Technology Co., Ltd. (subordinate Noear team). It is a new-generation Java enterprise application development framework. Built from scratch, it has its own independent standard specifications and an open ecosystem. Nearly 400,000 lines of code.

Main Features:

Official website: https://solon.noear.org/article/learn-quickstart

03 Best Practices

3.1 Install Plugin

Accustomed to SpringBoot's scaffolding, let's also try Solon's scaffolding, which requires us to install a plugin.

Plugin address: https://plugins.jetbrains.com/plugin/21380-solon

After installation is complete,

Now you can create a Module just like with SpringBoot.

To build a Web project, you need to select the Web scaffolding.

3.2 Introduce Dependencies

After selecting the scaffolding, dependencies are automatically introduced:

<!-- Solon Web Servlet -->
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>solon-lib</artifactId>
</dependency>

<dependency>
    <groupId>org.noear</groupId>
    <artifactId>solon-server-jetty</artifactId>
</dependency>

Or directly introduce:

<!-- Web rapid development integration package (includes solon-core + an HTTP server) -->
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>solon-web</artifactId>
</dependency>

3.3 Controller Layer

The startup class is automatically generated:

@SolonMain
public class App {
    public static void main(String[] args) {
        Solon.start(App.class, args);
    }
}

It is very similar to the SpringBoot startup class.

@Controller
public class FooController {

    @Inject
    private UserService userService;

    @Get
    @Mapping("/hello")
    public String hello() {
        return "hello Solon";
    }

    @Get
    @Mapping("/getUser")
    public User getUser() {
        return userService.getUser();
    }

    @Get
    @Mapping("/path/{random}")
    public String getPath(@Path("random") String random) {
        return "path: " + random;
    }
}

Services are injected using the @Inject annotation.

3.4 Service Layer

public interface UserService {
    User getUser();
}

// -------------------------------------
    
@Component
public class UserServiceImpl implements UserService {
    @Override
    public User getUser() {
        return new User(new Random().nextLong(), "ws", "developer", 18   );
    }
}

The service layer is marked with @Component.

3.5 Testing

Startup is indeed very fast:

The overall feeling is quite good. What do you think, folks?

04 Summary

The above demo is just a simple Web test. Solon's ecosystem is quite complete, and there is much more. If you are interested, go give it a try.