1

i have a strange problem with mapstruct and springboot 3, when i try to compile the native application. I get this error: Caused by: java.lang.ClassNotFoundException: Cannot find implementation for it.company.example.mapper.TestMapper at org.mapstruct.factory.Mappers.getMapper(Mappers.java:75) ~[na:na] at org.mapstruct.factory.Mappers.getMapper(Mappers.java:58) ~[na:na]

Is mapstruct working with springboot native? Thank you!

I've tryed a lot of modification, but i can't figure out what is the problem, maybe the mapstruct annotation processor is not working with native compilation?

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Mar 19 '23 at 01:21

1 Answers1

0

Don't use:

MyMapper mapper = Mappers.getMapper(MyMapper.class);

but annotate your mapper with: @Mapper(componentModel = SPRING)

then let spring inject mapper bean, it should work:

private final RepositoryMapper mapper;
// write setter or constructor injector
ahuemmer
  • 1,653
  • 9
  • 22
  • 29