I suspect the problem is that Spring is introducing an AOP proxy that implements MyInterface - perhaps for transaction management or caching purposes. Are any of the MyBean methods annotated with @Transactional or annotated with any other annotation?
Ideally, you probably want to reference MyBean by interface type - this should fix the problem.
@Component public class MyOtherBean { @Autowired private MyInterface myBean; ... }
If you have more than one bean that implements MyInterface, then you always qualify your bean by name.
@Component public class MyOtherBean { @Autowired @Qualifier("myBean") private MyInterface myBean; ... }
source share