Tell me how to use Soring DI in Java using a constructor. For example interface Enimal.java
public interfase Enimal(){ void say(); } And there are 2 implementations of this interface: Cat.java & Dog.java:
public class Cat implement Enimal{ public void say(){ System.out.println("Say myau"); } } public class Dog implement Enimal{ public void say(){ System.out.println("Say gav"); } } And there is a Service for working with higher classes:
public class ModelService{ private Enimal enimal; public ModelService(Enimal enimal){ this.enimal = enimal; } public void saySomething(){ enumal.say(); } } How can I create a ModelService object each time with passing different objects? For example, now I need to use the Cat class, and then I need to use Dog?