Working with Spring, Java > 1.8 and Mapstruct 1.4.2.Final.
The mappers generated for Spring ( componentModel = "spring") are implementing an interface, annotated with @Component, so they don't need to be public, they can be package-private by default.
They are meant to be injected by Spring in other classes/services, so the usual client code don't needs to do new MyMapperImpl();
Can you add a way to generate package-private implementations?
In a project, it can be detected by running test using ArchUnit ( this test with fail due to MapStruct generated classes).
ArchRuleDefinition.noClasses()
.that()
.haveSimpleNameEndingWith("Impl")
.should().bePublic()
.because("Implementations don't need to be public")
.check(new ClassFileImporter().withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS).importPackages("my.nice.pacakge"));
Working with Spring, Java > 1.8 and Mapstruct 1.4.2.Final.
The mappers generated for Spring (
componentModel = "spring") are implementing an interface, annotated with@Component, so they don't need to be public, they can be package-private by default.They are meant to be injected by Spring in other classes/services, so the usual client code don't needs to do
new MyMapperImpl();Can you add a way to generate package-private implementations?
In a project, it can be detected by running test using ArchUnit ( this test with fail due to MapStruct generated classes).