GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Generated mappers for Spring can be package-private · Issue #2513 · mapstruct/mapstruct

Generated mappers for Spring can be package-private #2513

New issue
Copy link
New issue
Copy link
Closed
#4071
Closed
Generated mappers for Spring can be package-private#2513
#4071
Copy link
Labels
enhancement
Milestone
1.7.0.Beta2

Description

@pdelaby
pdelaby
opened on Jul 13, 2021
Issue body actions

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"));
Reacted by Raimund Klein

Activity

  1. hduelme
    closed this as completedin #4071on Jun 24, 2026
  2. hduelme
    added a commit that references this issue on Jun 24, 2026

    #2513 Define new enum ClassAccessibility (#4071)

    f5253e8
  3. filiphr
    added
    enhancement
    on Jun 24, 2026
  4. filiphr
    added this to the 1.7.0.Beta2 milestone on Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      • 1.7.0.Beta2

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.