I'm using one mapper generated with MapStruct:
@Mapper public interface CustomerMapper { Customer mapBankCustomerToCustomer(BankCustomerData bankCustomer); } The default component model is spring (set in pom.xml)
<compilerArg>-Amapstruct.defaultComponentModel=spring</compilerArg> I have a service in which I inject the customer mapper and works fine when I run the application
@Autowired private CustomerMapper customerMapper; But when I run unit tests that involves @SpringBootTest
@SpringBootTest @AutoConfigureMockMvc @RunWith(SpringRunner.class) public class SomeControllerTest { @Mock private SomeDependency someDependency; @InjectMocks private SomeController someController; @Test public void shouldDoSomething() { ... } } I get an org.springframework.beans.factory.UnsatisfiedDependencyException
Unsatisfied dependency expressed through field 'customerMapper'