This repository contains the mica project, a Spring Cloud enhanced toolkit.
The project uses Maven for build and dependency management. Java Version: 17
- Full Build (Install):
mvn clean install -DskipTests
- Run All Tests:
mvn test - Run Tests in a Specific Module:
mvn -pl mica-core test - Run a Single Test Class:
# Run from root, specifying the module is recommended but optional if unique mvn -pl mica-core test -Dtest=StringUtilTest
- Run a Single Test Method:
mvn -pl mica-core test -Dtest=StringUtilTest#testFormat1
- The project uses
.editorconfigfor formatting rules. - Java: Use Tabs for indentation.
- XML/JSON/YAML: Use Spaces (2 or 4 as per file type, check
.editorconfig). - Encoding: UTF-8.
- Indentation: MUST use Tabs for
.javafiles (as defined in.editorconfig). - Naming:
- Classes:
PascalCase - Methods/Variables:
camelCase - Constants:
UPPER_SNAKE_CASE
- Classes:
- Imports:
- Group imports: Standard Java -> javax/jakarta -> org/com -> net.dreamlu.
- Wildcard imports (e.g.,
import org.springframework.util.*;) are used in existing code, but specific imports are preferred for clarity unless importing many classes from a package.
- Annotations:
- Use
@Nullable(org.jspecify.annotations.Nullable) for nullable parameters/returns. - Use Spring's
@Contractwhere applicable.
- Use
- Lombok: The project uses Lombok (e.g.,
@Data,@RequiredArgsConstructor,@Getter,@Setter). Use it to reduce boilerplate. - Comments:
- Javadoc is required for public classes and methods.
- Existing comments and Javadoc are in Chinese. Maintain this convention if modifying existing code or adding new utilities.
- Modules: The project is split into multiple modules (
mica-core,mica-http, etc.). - Dependencies:
- Versions are managed in the root
pom.xmlormica-bom. Avoid hardcoding versions in submodules; use managed properties. - Utilize
mica-autofor auto-configuration generation if creating starters.
- Versions are managed in the root
- Framework: JUnit 5 (
org.junit.jupiter.api). - Assertions: Use
org.junit.jupiter.api.Assertions. - Location: Tests reside in
src/test/java. - Naming: Test classes should end with
Test(e.g.,StringUtilTest). - Scope: Test classes and methods should generally be package-private (default in JUnit 5), public is not required.
- Use standard Java exceptions or project-specific exceptions (check
mica-coreforServiceExceptionetc.). - Avoid swallowing exceptions; log or rethrow appropriately.
- Consistency: Always check surrounding code for style and patterns before editing.
- Utility Classes: Check
mica-corefor existing utilities (e.g.,StringUtil,ObjectUtil) before writing new ones to avoid duplication. - Configuration: Respect
pom.xmldependencies and versions.