Standardizing Service Names and Configuring the Mica Launcher for Spring Boot Microservices
This guide explains how to create clear, hierarchical service names for microservices, defines environment partitions, shows how to use the Mica launcher with Spring Boot, and demonstrates custom configuration, plugin extension, and code examples for streamlined backend development.
Service Name Specification
In microservices, a good service name should be self‑explanatory. The following conventions are recommended.
Small Development Team – Two Levels
Example: user-api First level: Service name
Second level: Service type
Multiple Development Teams – Three Levels
Place the group name first for quick identification.
Example: mica-user-api First level: Group name
Second level: Service name
Third level: Service type
Environment Partition
Vision
The launcher’s mission is to enable JAR files to start easily in any environment with minimal configuration, reducing learning cost and allowing rapid onboarding.
Environment Types
dev (development), test (testing), ontest (online testing), prod (production); default is dev.
Startup Environment Variables
Java command line
java -jar app.jar --spring.profiles.active=devJAVA_OPTS
set JAVA_OPTS="-Dspring.profiles.active=test"Annotation (JUnit)
@ActiveProfiles({"junittest","productprofile"})Environment Variable
SPRING_PROFILES_ACTIVE (uppercase)Usage
The Mica launcher adds a service‑name parameter to the standard Spring Boot starter, making the service name explicit during launch.
Maven
<dependency>
<groupId>net.dreamlu</groupId>
<artifactId>mica-launcher</artifactId>
</dependency>Gradle
implementation "net.dreamlu:mica-launcher"Example main class:
@SpringBootApplication
public class MicaExampleApplication {
public static void main(String[] args) {
MicaApplication.run("mica-example", MicaExampleApplication.class, args);
}
}Note: When using mica-launcher, combine it with mica-test for unit testing (see the Mica test documentation).
Launcher Auto‑Configuration
You can inject MicaProperties to read launcher variables such as env.
Custom configuration can be added via mica.prop in configuration files and accessed through MicaProperties.
Key configuration items:
mica.env (default: dev) – read‑only environment variable.
mica.is-local (default: false) – read‑only flag for local development.
mica.prop – custom properties prefixed with
mica.prop.Custom Configuration Example
mica:
prop:
site-name: 如梦技术
site-url: https://www.dreamlu.netReading Configuration
@Autowired
private MicaProperties micaProperties;
public boolean savePost() {
String siteName = micaProperties.get("site-name");
String siteUrl = micaProperties.get("site-url");
// ...
}Launcher Plugin Extension
The launcher aims to simplify injection of common configurations. mica-log4j2 is an example extension.
Extensions are built using Java SPI; refer to Java SPI documentation for details.
Implementing LauncherService
/**
* Launcher extension for component discovery
*/
public interface LauncherService {
/**
* Process SpringApplicationBuilder during startup
*/
void launcher(SpringApplicationBuilder builder, Environment env, String appName, String profile, boolean isLocalDev);
}Creating the SPI File
Place a file at META-INF/services/net.dreamlu.mica.launcher.LauncherService containing the fully qualified class name of your implementation, e.g., net.dreamlu.mica.log.LogLauncherServiceImpl.
Open‑Source Recommendations
Spring Boot microservice toolkit – Mica: https://gitee.com/596392912/mica pig – powerful microservice framework: https://gitee.com/log4j/pig SpringBlade – complete production solution: https://gitee.com/smallc/SpringBlade
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Architecture Diary
Committed to sharing original, high‑quality technical articles; no fluff or promotional content.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
