A Spring Boot application structured with hexagonal architecture backed by the Spring Modulith library for modular design and enforcement, implemented as a single Gradle project The idea was inspired by a blog post and addresses some practical challenges that are often overlooked in similar examples.
package-info.java files managed by Spring Modulith define allowed dependencies.
For example, the persistence outbound adapter may only access shared domain classes and related order ports:
@ApplicationModule(allowedDependencies = {"architecture", "domain", "order"})This means it does not have access to classes from the rest inbound adapter.