Java Zero to All All questionsPractise free
Interview questions › Real-World Java Backend Architecture › Multi-Module Maven Project Design

How do you actually enforce module boundaries so they don't erode over time?

Level IV · SeniorMulti-Module Maven Project Design
Short answer

Layer three mechanisms. First, the Maven module graph itself: if web only depends on application, it physically cannot import infrastructure classes without adding the dependency, which would be an obvious code-review smell.

Explanation

Second, maven-enforcer with banned-dependency rules fails CI if someone declares an illegal direct dependency. Third, ArchUnit tests assert at the package level that, for instance, no domain class imports org.springframework and controllers don't touch repositories, catching violations that sneak in transitively. Relying on discipline alone fails; combining structural prevention with automated tests in the build is what keeps the architecture intact as the team grows.

Common mistakes
  • Relying on code review alone.
  • Not using ArchUnit or Maven Enforcer rules.

Can you say this out loud in two minutes? Drill it in a timed mock interview, with flashcards and runnable code for Multi-Module Maven Project Design.

Practise free

More on Multi-Module Maven Project Design