Unlock Faster Spring Cloud Development with Mica: A Powerful Backend Toolkit

Mica is a lightweight Java 8‑based Spring Cloud extension that simplifies microservice development by providing auto‑generated configurations, a fluent HTTP client, social login SDKs, customizable Ribbon rules, and extensive update notes, all without third‑party dependencies, making it a core backend toolkit for cloud-native applications.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
Unlock Faster Spring Cloud Development with Mica: A Powerful Backend Toolkit

Mica (Cloud Mineral)

Mica, symbolizing the core of cloud services, enhances Spring Cloud functionality, making service development faster and more convenient.

Mica Core Dependencies

Mica is built on Java 8, has no legacy baggage, and supports both traditional Servlet and Reactive (WebFlux). It uses mica-auto to auto‑generate spring.factories and spring‑devtools.properties, depending only on Spring Boot and the Spring Cloud suite, without any third‑party libraries.

Spring: 5.x

Spring Boot: 2.1.x

Spring Cloud: Greenwich version

Update Notes

✨ Added mica-plus-redis with MicaRedisCache bean, using the same redis commands.

✨ Configurable Redis serialization method.

✨ Improved logging and ordering of ReactiveRequestContextFilter for better use in Spring Cloud Gateway.

✨ Adjusted captcha base64 handling by adding the base64 image prefix.

✨ Added non‑hex methods for DigestUtil supporting MD5, SHA, HMAC and other signature algorithms.

🐛 Fixed bean copy Convert annotation support issue.

➕ Added new components: mica-http, mica-social, mica-plus-social, mica-plus-ribbon.

⬆️ Upgraded Spring Boot to 2.1.6.RELEASE.

⬆️ Upgraded Spring Cloud to Greenwich.SR1.

⬆️ Upgraded swagger‑bootstrap‑ui to 1.9.4.

mica-http: A Simpler, Easy-to-Use HTTP Toolkit

mica-http wraps OkHttp and provides a fluent API similar to HttpClient Fluent API.

Example Code

private String getUserEmail(String accessToken) {
    return HttpRequest.get("https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))")
            .addHeader("Host", "api.linkedin.com")
            .addHeader("Connection", "Keep-Alive")
            .addHeader("Authorization", "Bearer " + accessToken)
            .log()
            .execute()
            .asJsonNode()
            .at("/elements/0/handle~0/emailAddress")
            .asText();
}

public static void logBasic() {
    HttpRequest.post("https://www.baidu.com/do-stuff")
        .log(HttpLoggingInterceptor.Level.BASIC)
        .formBuilder()
        .add("a", "b")
        .execute()
        .asBytes();
}

Debug Logging

You can output detailed request logs using the .log() method.

19:50:27.223 [main] INFO net.dreamlu.http.Slf4jLogger - --> GET https://graph.qq.com/oauth2.0/token?code=code&client_id=clientId&client_secret=clientSecret&grant_type=authorization_code&redirect_uri=redirectUri http/1.1
19:50:27.228 [main] INFO net.dreamlu.http.Slf4jLogger - User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
...
19:50:27.671 [main] INFO net.dreamlu.http.Slf4jLogger - callback( {"error":100001,"error_description":"param client_id is wrong or lost "} );

mica-plus-social Third-Party Login SDK

Currently supports Gitee, OSChina, QQ, WeChat, Weibo, DingTalk, Baidu, Google, Facebook, LinkedIn and many other services.

Configuration

mica:
  social:
    qq:
      client-id: xxxxxx
      client-secret: xxxxx
      redirect-uri: http://www.dreamlu.net/api/qq/callback

Construct Authorization URL

@Autowired
private AuthQqRequest authRequest;

@GetMapping("auth/qq")
public String auth() {
    return "redirect:" + authRequest.authorize();
}

@GetMapping("callback/qq")
public String callback(String code) {
    AuthResponse authResponse = authRequest.login(code);
    // business logic
}

mica-plus-ribbon Custom Ribbon Rules for Easy Development

Features

Highest priority: same IP services (convenient for local multi‑service debugging).

Configurable IP or IP pattern, e.g., 172.21.0.* or 172.21.0.8*.

Configurable tag for future version releases (gray deployment) and possible extensions.

Configuration Items

enabled : true – Whether the rule is enabled.

prior-ip-pattern : (empty) – Priority IP list, supports wildcards such as 172.21.0.81, 172.21.0.8, 172.21.0..

tag : none – Service tag used for gray deployment, matches nacos.discovery.metadata.tag.

Configuration Example

mica:
  ribbon:
    rule:
        prior-ip-pattern:
        - 172.21.0.*

Documentation

Official site: https://www.dreamlu.net/#/doc/docs

Yuque (subscribe): https://www.yuque.com/dreamlu/mica

Example project: https://github.com/lets-mica/mica-example

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaSpring CloudRibbonSocial login
Java Architecture Diary
Written by

Java Architecture Diary

Committed to sharing original, high‑quality technical articles; no fluff or promotional content.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.