spring-modulith
spring-modulith copied to clipboard
Documentation contains invalid information
The "Fundamentals" section of the documentation contains a section about Open Modules that seems to be incorrect.
The example does not compile:
@org.springframework.modulith.ApplicationModule(
type = Type.OPEN
)
package example.inventory;
since the org.springframework.modulith.ApplicationModule annotation has no type attribute.
It has.
It has.
It has indeed 😵 … I was using version 1.1.3. Sorry about that.
Since we are here, I have one question. I would like to introduce Modulith in an existing project that is already partially organized in logical modules.
The monolith has a first-level common package, which contains a number of subfolders that are used for various "common" things, e.g. superclasses for rest controllers, events, etc.
Is using Type.OPEN to allow this pseudo-module to be accessed from the other modules?
From the docs, it seems that is also possible to achieve a similar result using the additionalPackages attribute of the @Modulithic annotation. Which of the two approaches is the more correct to allow a package and its subpackages to be accessed by multiple modules? Thanks!
An open module would be the way to go here. The Javadoc of additionalPackages clearly states (emphasis mine):
Defines which additional packages shall be considered as modulith base packages in addition to the one of the class carrying this annotation.