2016-12-22 16 views
-4

パーソン:春ブーツ多対多ジャクソン再帰

@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; 
    } 
} 

データベース: テーブルの人 table person

テーブルperson_friends table person_friends

なぜ "/ findAll"は無限ループの結果ですか?

+1

最初は、写真ではなく質問とともに、スニペットとしてコードを与える方がよい。ここでの質問を理解しやすい。第2に、2枚の画像が欠落しています。質問を編集して更新してください。 –

答えて

0

申し訳ありませんが、間違いました。データベースが不適切で、ビジネスロジックが間違っています。

関連する問題