У меня проблема с методом записи в Spring. Когда я пытаюсь отправить объект в базу данных, клиентское приложение зависает, и мне нужно прекратить его. Размещение объекта с помощью curl работает нормально. Я получаю журнал:
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Infinite recursion (StackOverflowError) (through reference chain: java.util.ArrayList[0]->dareq.Point["points"]->java.util.ArrayList[0]->dareq.Point["points"]->java.util.ArrayList[0]->dareq.Point["points"]->java.util.ArrayList[0]->dareq.Point["points"]
Клиентская сторона:
Класс балла:
public class Point {
private Long id;
private List<String> bssid = new ArrayList<>();
private List<Double> rssi = new ArrayList<>();
private double x;
private double y;
public Point()
{
}
public Point(Long id, List<String> bssid, List<Double> rssi, double x, double y){
this.id = id;
this.bssid = bssid;
this.rssi = rssi;
this.x = x;
this.y = y;
}
Почтовая функция:
public void postPoint()
{
RestTemplate restTemplate = new RestTemplate();
restTemplate.postForObject("http://localhost:5000/points", this, this.getClass());
}
Сторона сервера:
Контроллер:
@PostMapping("/points")
Points newPoints(@RequestBody Points newPoints){
return repository.save(newPoints);
}
Класс очков:
@Data
@Entity
public class Points {
private @Id @GeneratedValue Long id;
@Column
@ElementCollection
private List<String> bssid;
@Column
@ElementCollection
private List<Double> rssi;
private double x;
private double y;
Points (){
};
Points(List<String> bssid, List<Double> rssi, double x, double y){
this.bssid=bssid;
this.rssi=rssi;
this.x=x;
this.y=y;
}
}
Проверка журналов на сервере AWS, когда я пытаюсь опубликовать объект на клиенте, вызываются многие методы get:
78.28.26.200 - - [07/Jan/2019:00:34:31 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:32 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:32 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:32 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:32 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:32 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:33 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:33 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:33 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:33 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:33 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:33 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:33 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:34 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:34 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:34 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:34 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:34 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:34 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:34 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:35 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:35 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:35 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:35 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:35 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
78.28.26.200 - - [07/Jan/2019:00:34:36 +0000] "GET /points/ HTTP/1.1" 200 87 "-" "Java/1.8.0_172" "-"
Я буду очень признателен за любую помощь. Спасибо