Search code examples
javaspring-bootspring-boot-testmapstruct

Intellij doesn't see the generated class by MapStruct


When I use MapStruct in spring-boot it generates an impl class and I want to have access on that file to import in unit test but intellij doesn't see it

@SpringBootTest(classes={OrderMapperImpl.class})

and I got error

Can't find a symbol OrderMapperImpl

Solution

  • You can tell IntelliJ to pick up mapstructs generated classes as source files by right-clicking on the directory target/generated-sources/annotations > Mark directory as... > Generated Sources Root.

    If you have configured another output path you need to choose that instead.