The dependencies of some of the beans in the application context form a cycle
Use @Lazy
A simple way to break the cycle is by asking Spring to initialize one of the beans lazily. That is: instead of fully initializing the bean, it will create a proxy to inject it into the other bean. The injected bean will only be fully created when it’s first needed.
@Service
public class AServiceImpl implements AService {
private final ARepository aRepository;
public AServiceImpl(@Lazy ARepository aRepository) {
super();
this.aRepository = aRepository;
}
...
}
source: https://www.baeldung.com/circular-dependencies-in-spring
There's a simple fix for your original problem: Just remove @Repository from ARepositoryCustom and from ARepositoryImpl. Keep all the naming and interface/class hierarchies. They are all OK.