title: Can I control how spring controller method arguments are instantiated?
body: <p>Consider the following interface/object hierarchy in a spring project:</p>
  
  <pre><code>public interface MyInterface {
      //method defenitions
  }
  
  @Component
  @Scope(SCOPE_PROTOTYPE)
  public class MyClass implements MyInterface {
     //method implementations
  }
  </code></pre>
  
  <p>I use <code>MyClass</code> in a controller method where it is read from the requests body:</p>
  
  <pre><code>@RequestMapping(method = POST, value = "/posturi", consumes = "application/json")
  public void createEntity(@RequestBody MyClass myClass) {
      //handle request
  }
  </code></pre>
  
  <p>The jackson library is used to read json data and convert it to a java object. </p>
  
  <p>I would like to change the type of the parameter in the controller method from <code>MyClass</code> to <code>MyInterface</code>. This does not seem to work since the interface can't be instantiated with the <code>new</code> operator. But it <em>could</em> be created like this:</p>
  
  <pre><code>MyInterface instance = applicationContext.getBean(MyInterface.class);
  </code></pre>
  
  <p>Is it possible to make spring/jackson instantiate the object this way? I would like to do this so that my controller does not need to be aware of what implementation is used.</p>