A reusable, centralized library providing annotations, enums, models, common exceptions, and other shared components to support consistency and code reuse across Spring Boot-based microservices.
This project is designed to serve as a shared dependency for multiple microservices within a distributed architecture. By centralizing commonly used artifacts, it promotes:
- Code consistency across services
- Reduced duplication
- Better maintainability
- Faster development cycles
✅ Custom annotations (e.g., validation, logging, security)
✅ Shared enums for status codes, error types, environments, etc.
✅ Base response & error models for unified API structure
✅ Common exceptions with standardized error handling
✅ Utility classes (e.g., string utils, date/time utils)
✅ Global constants
✅ Fully compatible with Maven and Gradle-based Spring Boot projects
<dependency>
<groupId>com.triton</groupId>
<artifactId>ms-commons</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
implementation 'com.triton:ms-commons<:0.0.1-SNAPSHOT'
🔁 This library must be published to your Maven/Nexus repository or GitHub Packages for other services to consume it.
Module | Description |
---|---|
annotations |
Custom annotations for logging, security, etc. |
enums |
Shared enums like Status , ErrorCode , EnvironmentType |
models |
Common request/response wrappers, DTOs, and pagination models |
exceptions |
Custom base and application-level exceptions |
utils |
Utility classes for string, date, JSON operations |
constants |
Centralized constants used across services |
import com.triton.mscommons.enums.ApplicationEnvironment;
public class YourClass {
private ApplicationEnvironment env; // DEV, QA, STG and PROD
}
import com.triton.mscommons.exceptions.ResourceNotFoundException;
throw new ResourceNotFoundException("User not found with ID: " + id);
import com.triton.commons.models.BaseResponse;
return BaseResponse.success(userData);
ms-commons/
│
├── src/main/java/com/triton/mscommons/
│ ├── annotations/
│ ├── enums/
│ ├── models/
│ ├── exceptions/
│ ├── utils/
│ └── constants/
│
├── pom.xml
└── README.md
This library includes unit tests for core modules using JUnit 5 and Mockito. You can run tests via:
./mvnw test
or
./gradlew test
- Java 17+
- Spring Boot 3+
- Maven / Gradle
- JUnit 5
- Mockito
This project is licensed under the MIT License - see the LICENSE file for details.
[Ravikant Pal]
Backend Developer | Java & Spring Boot Enthusiast
LinkedIn • GitHub
Have suggestions or want to contribute? Feel free to open an issue or submit a pull request!