我有一个简单的Spring Boot Web应用程序.我正在尝试从服务器接收一些数据. Controller返回一个集合,但浏览器接收空JSON – 大括号的数量等于来自服务器的对象数,但其内容为空.
@RestController
public class EmployeeController {
@Autowired
private EmployeeManagerImpl employeeManagerImpl;
@RequestMapping(path="/employees",method = RequestMethod.GET)
public Iterableterableterable = employeeManagerImpl.getAllEmployees();
return employeesIterable;
}
}
在控制台中没有更多.有任何想法吗?
编辑:
Employee.java
@Entity
public class Employee implements Serializable{
private static final long serialVersionUID = -1723798766434132067L;
@Id
@Getter @Setter
@GeneratedValue
private Long id;
@Getter @Setter
@Column(name = "first_name")
private String firstName;
@Getter @Setter
@Column(name = "last_name")
private String lastName;
@Getter @Setter
private BigDecimal salary;
public Employee(){
}
}
最佳答案
我认为你应该使用Lombok作为类级别而不是字段级别.
@Entity
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Employee implements Serializable {}
这可以解决您的问题.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。