パーソン:春ブーツ多対多ジャクソン再帰
@Entity
@Table(name = "person")
public class Person{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@Column(name = "name", nullable = false, length = 30)
private String name;
@Column(name = "age", nullable = false, length = 2)
private int age;
@ManyToMany
private List<Person> friends;
}
PersonController:
@RestController
@RequestMapping("/person")
public class PersonController{
@Autowired
PersonService personService;
@RequestMapping(value = {"/findAll"}, method = RequestMethod.GET)
public Object findAll(){
List<Person> people = personService.findAll();
Map<String, Object> response = new HashMap<String, Object>();
response.put("msg", "王安生王person!");
response.put("people", people);
return response;
}
}
データベース: テーブルの人
テーブルperson_friends
なぜ "/ findAll"は無限ループの結果ですか?
最初は、写真ではなく質問とともに、スニペットとしてコードを与える方がよい。ここでの質問を理解しやすい。第2に、2枚の画像が欠落しています。質問を編集して更新してください。 –