I’m trying to test my RestClient service.
However when I execute the test I get
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountRepository' defined in org.app.domain.account.AccountRepository defined in @EnableJdbcRepositories declared on Application: Cannot resolve reference to bean 'org.springframework.data.jdbc.core.mapping.JdbcMappingContext' while setting bean property 'mappingContext'
Seems like it autoconfigure repository beans despide documentations of (@RestClientTest) says it disables full auto-configuration.
@ActiveProfiles({"test"})
@RestClientTest(value = {AccountServiceClient.class})
public class AccountServiceClientTest {
@Autowired
private AccountServiceClient serviceClient;
@Autowired
private MockRestServiceServer mockServer;
@Test
void testLoginFail() {
// stuff
assertThatCode(() -> mockServer.verify()).doesNotThrowAnyException();
}
}
@EnableCaching
@EnableJdbcRepositories(basePackages = "org.app.domain")
@SpringBootApplication(scanBasePackages = "org.app")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
I’ve tried to add in RestClientTest but didn’t work:
excludeAutoConfiguration = {
DataSourceAutoConfiguration.class,
JdbcRepositoriesAutoConfiguration.class,
JdbcClientAutoConfiguration.class,
JdbcTemplateAutoConfiguration.class
})
Is there a solution that exclude all repositories automatically instead of using @MockBean for each repo?