title: SpringBoot method that saves users is setting lastname as null
body: <p>I'm new at using SpringBoot (this is my first project) and I'm trying to create a simple controller to save users with a post method that requires a JSON RequestBody that also returns a JSON containing the same user as a response. The method seems to work well, I'm gettig a JSON back when I make the post request but for some reason the lastName of the User is always null, as you can see in the image.</p>
  <p><a href="https://i.stack.imgur.com/NeIC0.png" rel="nofollow noreferrer">Post method</a></p>
  <p>(I've used lombok to create getters, setters and constructors)</p>
  <p>My User entity is pretty simple:</p>
  <pre><code>package com.example.demo.entity;
  
  import lombok.AllArgsConstructor;
  import lombok.Data;
  import lombok.NoArgsConstructor;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  
  @Entity
  @Data
  @AllArgsConstructor
  @NoArgsConstructor
  
  public class User {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      Long userId;
      String firstName;
      String lastName;
      String email;
  
  }
  </code></pre>
  <p>And this is the UserController:</p>
  <pre><code>package com.example.demo.controller;
  
  
  import com.example.demo.entity.User;
  import com.example.demo.service.UserService;
  import lombok.extern.slf4j.Slf4j;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.*;
  
  import java.util.List;
  
  @Slf4j
  @RestController
  @RequestMapping(&quot;/users&quot;)
  public class UserController {
  
      @Autowired
      private UserService userService;
  
  
      @PostMapping(&quot;/&quot;)
      public User saveUser(@RequestBody User u) {
          log.info(u.toString());
          return userService.saveUser(u);
      }
  
      @GetMapping(&quot;/&quot;)
      public List&lt;User&gt; findAllUsers() {
          return userService.findAllUsers();
      }
  }
  </code></pre>
  <p>I supposed this is a dumb question but haven't found any similar post with a solution.</p>
  <p>Thanks a lot!</p>