title: inject spring repository into static method
body: <p>I generate a list of instances which implement interface CheckInterface
  using reflection, but some of those instances need to use JPA repository
  ,as they are new by reflection so Spring will not inject repository for them.
  So how can I inject repository into these instance</p>
  
  <p>Or how can I delegate these class to spring as @Bean and iterate them?</p>
  
  <pre><code>@Component
  @Log4j
  public class ValidationRegister {
  
  public static HashMap&lt;String, CheckItem&gt; itemHashMap = new HashMap&lt;&gt;();
  
  static {
      if (itemHashMap.size() == 0) {
          Reflections reflections = new Reflections(CheckItem.class.getPackage().getName());
          Set&lt;Class&lt;? extends CheckItem&gt;&gt; itemClasses =
                  reflections.getSubTypesOf(CheckItem.class);
  
          for (Class&lt;? extends CheckItem&gt; checkItemClass : itemClasses) {
              try {
                  itemHashMap.put(checkItemClass.getName(), checkItemClass.newInstance());
              } catch (Exception e) {
                  log.error("ValidationRegister fail : ", e);
              }
          }
      }
  }
  }
  
  public class LPHYCZ extends CheckItem {
  
  @Autowired
  ClaimDataEntityRepository claimDataEntityRepository;
  
  @Override
  public boolean check(ClaimRequest request, List&lt;String&gt; errorList) {
      ClaimDataEntity claimDataEntity = claimDataEntityRepository.findByClaimId(request.getClaimId());
      if (claimDataEntity != null) {
          return true;
      }
      return false;
  }
  }
  </code></pre>
  
  <blockquote>
    <p>When I get instance of LPHYCZ from ValidationRegister.itemHashMap its
    claimDataEntityRepository will be null</p>
  </blockquote>