title: Autowire Enum in Spring Bean
body: <p>Iam trying to autowire an enum inside a spring Bean.I have not tried this before and not sure what is missing but when i do that i am getting parameter 0 of constructor in required a bean of type java.lang.string error.
  Please find below the code i have created.</p>
  
  <pre><code>public interface TokenGenerator{
   String generateToken();
  }
  
  @Service
  public enum  TokenGeneratorImpl implements TokenGenerator{
  
  INSTANCE;
  
  private string token;
  
  public string  generateToken(){
      if(token == null){
        token="new token";
      }
  
      return token;
     }
  }
  
  
  @Service
  public class ConnectionService {
  
   @Autowired
   private TokenGenerator generator
  
   public void getConnection(){
     for(int i =0; i&lt; 1000; i++){
           Thread t = new Thread(() -&gt; generator.generateToken());
            t.start();
        }
     }
   }
  </code></pre>
  
  <p>There are two issues:
  1) Autowiring is not working  and I am getting </p>
  
  <pre><code>parameter 0 of constructor in required a bean of type java.lang.string error
  </code></pre>
  
  <p>2) If i call directly the Enum and generate the token then i found that this code is not thread safe and want to understand how I can make it thread safe</p>