title: @Autowired not work inside class that class instance create using reflection
body: <p>I am creating spring boot application. In this application there have set of logic class and this logic class instance create using reflection(base on some condition logic is change that's the reason i use to reflection) In side logic class i try to Autowired my repository class but it not work. That logic class annotated using @Component but it not working. </p>
  
  <p>is there have any way to do that. spring use reflection to autowired class therefor  i don't know after using reflection myself, use @Autowired possible or not. </p>
  
  <p><strong>Code :</strong> </p>
  
  <pre><code>interface ILogic{
      void saveUser();
      // set of methods
  }
  
  @Repository
  interface ARepository extends JpaRepository&lt;ARepository,Integer&gt;{}
  
  @Component
  class ALogic implement ILogic{
      private final ARepository aRepository;
      private final BRepository bRepository;
      @Autowired
      public Alogic(ARepository aRepository, BRepository bRepository){
      // code stuff 
      }
      // implementation of methods in ILogic interface
  } 
  
  @Component
  class BLogic implement ILogic{
      private final ARepository aRepository;
      private final BRepository bRepository;
      @Autowired
      public Alogic(ARepository aRepository, BRepository bRepository){
          // code stuff 
      }
      // implementation of methods in ILogic interface
  }  
  
  class CreateConstructor{
      public ILogic getLogicInstance(){
          // give logic class instance base on some condition
      }
  }
  
  @Service
  class userService{
  
      CreateConstructor createConstructor= new CreateConstructor();
      public void saveUser(){
          createConstructor.getLogicInstance().saveUser();
      }
  }
  </code></pre>
  
  <p>repository class instance are not create inside Logic class.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <pre><code>public ILogic getLogicInstance(String className) {
      try {
          String packageName = MultiTenantManager.currentTenant.get();//  this return required logic class included  package name. 
          Class&lt;?&gt; constructors = Class.forName("lk.example."+packageName+"."+className);
          return (ILogic) constructors.getConstructor().newInstance();
      } catch () {}
  }
  </code></pre>