How to make MapStruct in a custom dependency and use it for different projects?

31 views
Skip to first unread message

Tin Nit

unread,
Oct 26, 2020, 11:11:15 PM10/26/20
to mapstruct-users
Hi,
I'm new to MapStruct and like it so much, it's amazing to handle dto mapping.
Now i want to put my mapper into a custom dependency, e.g. Human.jar, then import into my different Spring microservices. And it throws the exception
No found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
i've found some related questions but they're putting the mapper and service under the same project resource, which is not my case.
Please advise if there is a way can achieve it.
Thank you!

Human.jar
@Mapper(componentModel = "spring", uses = {})
public abstract class HumanMapper {
public abstract HumanDTO toDto(Human human);
}

Spring microservice Human
@ComponentScan(basePackages = {"com.human.mapper"})
@SpringBootApplication
public class SpringMsHumanApp implements InitializingBean {
     @Autowired
      private HumanMapper humanMapper;
}


Reply all
Reply to author
Forward
0 new messages