How deepaksrivastav/spring-boot-multimodule works
Purpose and Runtime
A Spring Boot multi-module proof of concept demonstrating layered Java application packaging. The application module is the runnable web application, launched via its Spring Boot main class and served by embedded Tomcat.
Entry points:
• application/src/main/java/sample/multimodule/SampleWebJspApplication.java
• application/src/main/java/sample/multimodule/web/WelcomeController.java
Maven Module Composition
The root Maven aggregator coordinates six modules and shared dependency management:
• pom.xml
• application/pom.xml
• service-impl/pom.xml
Dependencies follow a strict layer direction: application → service implementation → repository/service API → model. The model module is dependency-free and forms the shared domain boundary.
Web and Presentation Boundary
The application module owns HTTP handling, application properties, and server-rendered presentation. WelcomeController receives browser requests and delegates account lookup rather than accessing persistence directly.
Relevant paths:
• application/src/main/java/sample/multimodule/web/WelcomeController.java
• application/src/main/resources/templates/welcome/show.html
• application/src/main/resources/application.properties
The presentation response is an HTML template populated with account information.
Service Contract and Business Layer
service-api defines the stable account-service interface and domain-specific missing-account failure independently of its implementation:
• service-api/src/main/java/sample/multimodule/service/api/AccountService.java
• service-api/src/main/java/sample/multimodule/service/api/AccountNotFoundException.java
service-impl supplies the Spring-managed implementation, bridging the service contract to the repository:
• service-impl/src/main/java/sample/multimodule/service/impl/AccountServiceImpl.java
• service-impl/pom.xml
This split allows callers such as web code to depend on service abstractions while persistence remains internal to implementation wiring.
Persistence Boundary
The repository module encapsulates account data access and depends on the domain model:
• repository/src/main/java/sample/multimodule/repository/AccountRepository.java
• repository/pom.xml
Service implementation is the intended consumer of this repository. No separate database or external infrastructure is identified in the supplied repository structure.
Shared Domain Model
The model module contains cross-layer entities/value objects, specifically the account domain object:
• model/src/main/java/sample/multimodule/domain/entity/Account.java
• model/pom.xml
Account is shared by repository, service API, service implementation, and application-facing flows, making it the primary data carrier.
Primary Request Flow
A browser request reaches embedded Tomcat and Spring MVC in the application module. WelcomeController invokes AccountService; its implementation queries AccountRepository; the resulting Account returns through the service boundary to the controller, which renders the welcome HTML view. Missing-account behavior is represented by AccountNotFoundException.
The executable distribution is built from the root and run from application; runtime configuration remains local to the application module.
Main entry points: AccountServiceImpl.java Account Service Implementation · AccountService.java Account Service · pom.xml Application Module · WelcomeController.java Welcome Controller
Components 12
Maven Build
- Root Aggregator · Coordinates the six modules and shared dependency management.
pom.xml
Runnable Application
- Application Module · Runnable web application and composition boundary.
application/pom.xml - Boot Main Class
application/src/main/java/sample/multimodule/SampleWebJspApplication.java - Embedded Tomcat / Spring MVC
- Welcome Controller
application/src/main/java/sample/multimodule/web/WelcomeController.java - Welcome HTML View
application/src/main/resources/templates/welcome/show.html - Application Properties
application/src/main/resources/application.properties
Service Layer
- Account Service · Stable account lookup abstraction used by callers.
service-api/src/main/java/sample/multimodule/service/api/AccountService.java - Account Not Found
service-api/src/main/java/sample/multimodule/service/api/AccountNotFoundException.java - Account Service Implementation · Bridges the service contract to repository access.
service-impl/src/main/java/sample/multimodule/service/impl/AccountServiceImpl.java
Domain & Persistence
- Account Repository · Encapsulates account data access.
repository/src/main/java/sample/multimodule/repository/AccountRepository.java - Account · Shared cross-layer account data carrier.
model/src/main/java/sample/multimodule/domain/entity/Account.java
Connections 14
- Root Aggregator → Application Module: aggregates
- Application Module → Boot Main Class: launches
- Boot Main Class → Embedded Tomcat / Spring MVC: starts
- Application Properties → Boot Main Class: configures
- Embedded Tomcat / Spring MVC → Welcome Controller: routes requests to
- Welcome Controller → Account Service: invokes
- Account Service Implementation → Account Service: implements
- Account Service Implementation → Account Repository: queries
- Account Repository → Account: loads
- Account Service → Account: returns
- Account Service → Account Not Found: signals
- Welcome Controller → Welcome HTML View: renders with Account
- Application Module → Account Service Implementation: depends on
- Account Service Implementation → Account Repository: module dependency