title: JsonIdentityInfo Resolver instantiated in Spring Context
body: <p>How can I register an ObjectIdResolver to an Spring/Jackson object mapper so that the ObjectIdResolver class gets instantiated by Spring? I would like to use dependency injection in my ObjectIdResolver class.</p>
  
  <p><strong>ObjectIdResolver.java</strong></p>
  
  <pre><code>@Component
  public class UserIdResolver implements ObjectIdResolver {
  
      @Autowired
      UserConverter userConverter;
  
      @Override
      public void bindItem(ObjectIdGenerator.IdKey id, Object ob) { }
  
      @Override
      public Object resolveId(ObjectIdGenerator.IdKey id) {
          return userConverter.convert((Integer)id.key);
      }
  
      @Override
      public boolean canUseFor(ObjectIdResolver resolverType) {
          return getClass().isAssignableFrom(resolverType.getClass());
      }
  
      @Override
      public ObjectIdResolver newForDeserialization(Object c) {
          return this;
      }
  
  }
  </code></pre>
  
  <p><strong>Order.java</strong></p>
  
  <pre><code>public class Order  {
  
      @JsonIdentityInfo(
              generator = ObjectIdGenerators.PropertyGenerator.class,
              property = "id",
              resolver = UserIdResolver.class,
              scope = User.class
      )
      @JsonIdentityReference(alwaysAsId=true)
      private User user;
  
  ..
  
  }
  </code></pre>
  
  <p><strong>spring-servlet.xml</strong></p>
  
  <pre><code>&lt;bean id="objectMapper" class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean"
        p:indentOutput="true" p:simpleDateFormat="yyyy-MM-dd'T'HH:mm:ss.SSSZ" /&gt;
  
  &lt;bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"
        p:targetObject-ref="objectMapper" p:targetMethod="registerModule"&gt;
      &lt;property name="arguments"&gt;
          &lt;list&gt;
              &lt;bean class="com.fasterxml.jackson.datatype.joda.JodaModule" /&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;mvc:annotation-driven conversion-service="conversionService"&gt;
      &lt;mvc:message-converters&gt;
          &lt;bean class="org.springframework.http.converter.StringHttpMessageConverter"/&gt;
          &lt;bean class="org.springframework.http.converter.ResourceHttpMessageConverter" /&gt;
          &lt;bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"&gt;
              &lt;property name="objectMapper" ref="objectMapper" /&gt;
          &lt;/bean&gt;
      &lt;/mvc:message-converters&gt;
  &lt;/mvc:annotation-driven&gt;
  </code></pre>