I am new to Springs so please don't mind if my question is dumb
I have a class which implements two interfaces
public class AAA implements BBB, CCC {
}
public interface BBB {
void method BBB_method();
}
public interface CCC {
void CCC_method();
}
I am defining bean object in Context class as follows:
public class Context {
@Bean
public BBB myObject(){
return new AAA();
}
@Bean
public CCC myObject(){ //Issue is here
return new AAA(); //Duplicate API name not allowed
}
}
I have autowired the beans in 2 different class as follows:
@Autowired
private BBB myObject;
@Autowired
private CCC myObject;
What should be the best way to autowire this and define the bean in the Context class? And does defining 2 bean object in Context.java make sense? How to resolve this situation where I want my bean to be autowired to two different interfaces ( and object name being the same..as in my case its myObject) ? Your response is very much appreciated. Thank You !