0

I have a problem, I have an interface and that interface is implemented in two classes. I need to created two objects of one interface. So, one object for class aCluud and other for bCluud, and can access method through the object. Example:

Interface:

public interface clousservice{
    public void getA();
    public void getB();
}

Classes:

public class aCluud implements clousservice{
    public void getA(){
        //some Java code
    }

    public void getB() {
        //some Java code
    }
}

public class bCluud implements clousservice{
    public void getA(){
        //some Java code
    }

    public void getB() {
        //some Java code
    }
}

Access interface in different classes

public class task {
    private final  clousservice service;

    public task(clousservice service){
        this.service = service
    }
}

When I start a server, I get below message

Parameter 0 of constructor in au.com.task.Task required a single bean, but 2 were found:

How I can achieve this functionality? For this I am using Java 11 and Spring Boot.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

0 Answers0