title: Injecting java.util.Random on a constructor
body: <p>I have a class HiddenNumber with this constructor:</p>
  
  <pre><code>public HiddenNumber(java.util.Random random, int maxNumberOfDigits) {
    /* some code */
  }
  </code></pre>
  
  <p>I´m trying to use annotations for DI as:</p>
  
  <pre><code>@Autowired
  public HiddenNumber(@Value("T(java.util.Random") random, 
      @Value("4")int maxNumberOfDigits) {
    /* some code */
  }
  </code></pre>
  
  <p>But it doesn't work. I also tried:</p>
  
  <pre><code>@Autowired
  public HiddenNumber(@Value("#{T(java.util.Random}") random, 
      @Value("4")int maxNumberOfDigits) {
    /* some code */
  }
  </code></pre>
  
  <p>If I do:</p>
  
  <pre><code>@Autowired
  public HiddenNumber(Random random, @Value("4") int maxNumberOfDigits) {
    /* some code */
  }
  </code></pre>
  
  <p>And in the app-context.xml do:</p>
  
  <pre><code>&lt;bean class="java.util.Random" /&gt;
  </code></pre>
  
  <p>It works ok. But of course I prefer to do only annotations.</p>
  
  <p>What is the correct way to inject java.util.Random?</p>
  
  <p>Thanks.</p>