title: How do I setup/configure Jackson annotations to work in Spring MVC?
body: <p>I inherited a project in Spring MVC 3.1.1 and I need to use Jackson to serialize objects to JSON.  I have an object class like:</p>
  
  <pre><code>public class User {
      Integer id;
      String name;
  
      public Integer getId() {
          return id;
      }
      public void setId(Integer id) {
          this.id = id;
      }
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>and a controller like this:</p>
  
  <pre><code>@Controller
  @RequestMapping(value =  "/home")
  public class homeController {
      @RequestMapping(value = "/")
      public @ResponseBody User home() {
          User user;
          user = new User();
  
          user.setId(1);
          user.setName("Drew");
  
          return user;
      }
  }
  </code></pre>
  
  <p>Navigate to /home and I get:</p>
  
  <pre><code>{"id":1,"name":"Drew"}
  </code></pre>
  
  <p>Great, that's the first step down.  Now, if I want to ignore the "id" parameter, the Jackson documentation says I should use the @JsonIgnore annotation.  The problem I am having is that NetBeans can't locate any of the annotation packages to import for Jackson, so I can't use the annotations.  I tried downloading the Jackson 2.2 jars and adding those to my project (which then allows me to import the annotations), but the @JsonIgnore annotation has no effect when I do that.</p>
  
  <p>I suspect that I'm missing either a jar file from Spring MVC or I need to configure something in the project's XML files, how would I go about finding out whether either (or neither) is the case?  I'm relatively new to Java and I've never used Spring before, so if there's some additional information that would be helpful that I didn't know you would need, please ask and I will do my best to locate it.  Thanks in advance for any assistance you can give!</p>
  
  <p>edit:</p>
  
  <p>To clarify, I have tried using annotations like this:</p>
  
  <pre><code>public class User {
      Integer id;
      String name;
  
      @JsonIgnore
      public Integer getId() {
          return id;
      }
      public void setId(Integer id) {
          this.id = id;
      }
      @JsonProperty("userName")
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>and like this:</p>
  
  <pre><code>@JsonIgnoreProperties({"id"})
  public class User {
      Integer id;
      String name;
  
      public Integer getId() {
          return id;
      }
      public void setId(Integer id) {
          this.id = id;
      }
      @JsonProperty("userName")
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
  }
  </code></pre>
  
  <p>and the returned JSON is always the same:</p>
  
  <pre><code>{"id":1,"name":"Drew"}
  </code></pre>