To my experience, for small apps or very small services you are right, maven modules make thing unnecessary complex in two ways: technical and cognitive.
However, modules can be of much help when:
Services are complex and we need a way to visualize their most relevant boundaries so that developers can find or add features in the right place quickly.
Decomposing services. Even microservices can be composed of several but smaller services. Using maven modules can provide us with valuable feedback about the interaction of the components and the best way to decouple them. Or a reason to leave where they are. Moving code to a standalone process will be easier this way.
A well-modular application can enforce a healthy separation of concerns too and reduce the coupling between elements of the application.
Modules can be the tactical answer to a strategic question or need too. For example:
- We need/want to develop, evolve and maintain features or capabilities separately. In other words, providing them with different development life cycles.
- Versioning of code or logic
- Code reuse (as shared libs, aka microkernels)
- Services' archetyping (look for maven archetypes for more information)
If services implement the hexagonal (micro)service implements a Hexagonal architecture, one moreanother advantage is in the "adapters". These can be implemented latermoved to a different module, constraining any possible coupling between abstractions and replaced without changing the core ofimplementation details. At the applicationsame time, or the logicnew module can be implemented in parallel. While one member of the module we are workingteam is focused on the business, others focus on the adapters. It means that we can move
Testing also matters. It's not the implementation details tosame testing a specificsmall module (say *infrastructure")in terms of time and let its implementation for later or code it in parallel with the business logiccomplexity) than testing a whole service which usually involves many more "moving-things" to take into account.