@Repository
public interface MyRepository extends CrudRepository<Custom, Long> {}
@Service
@RequiredArgsConstructor
public class MyServiceImpl implements MyServiceInterface {
private final MyRepository repository;
}
I use test configuration with instructions for bean construction for testing.
How to create @Bean for MyRepository interface?
@TestConfiguration
@EnableJpaRepositories(basePackages = "com.example.app")
public class TestBeans {
@Bean
MyServiceInterface getMyService() {
return new MyServiceImpl(getMyRepository());
}
@Bean
MyRepository getMyRepository() {
return null; // what should be here?
}
}