title: How to autowire Spring service with Class name?
body: <p>I have multiple services and I want to autowire this services dynamically with using their class names. I have a method named "runCustomService" and this methods takes service's class names as input parameter (like "Service1" or "Service2"). I want to autowire these services and call its run method. Is there any way to do this?</p>
  
  <pre><code>@Service
  public class Service1 extends BaseService{
  
      @Autowired
      private AnotherService anotherService;
  
      public void run(){ .... }
  }
  
  @Service
  public class Service2 extends BaseService{
  
      @Autowired
      private AnotherService anotherService;
  
      public void run(){ .... }
  }
  
  
  public void runCustomService(String serviceClassName){        
      BaseService baseService = //Create baseService object from serviceClassName
      baseService.run();
  }
  </code></pre>