I have an interface
public interface ParentService{}
And Two Implementation Class
@Service("child1service")
public class Child1 implements ParentService{}
@Service("child2service")
public class Child2 implements ParentService{}
Now my Controller
public class ServeChild1Controller extendds AbstractController{
@Autowired
public ServeChild1Controller(@Qualifier("child1service") ParentService child1service){
super(child1service)
}
Similarly there is ServeChild2Controller..
So when i run I get the following error
Error for ServeChild1Controller: No unique bean of type [com.service.ParentService] is defined: expected single matching bean but found 2 child1service, child2service
Am trying to read more about these Annotations but not able to resolve it ..
Any pointers will be of help
Thanks
In order to use a specific instance you need to provide Annotate the service with @Qualifier(id) and in the constructor anotate the parameter with @Qualifier again, as follows:
And you constructor: