Как исправить ошибку определения типа в приложении Spring Boot?JAVA

Программисты JAVA общаются здесь
Anonymous
Как исправить ошибку определения типа в приложении Spring Boot?

Сообщение Anonymous »

Я создаю приложение Spring Boot, которое использует класс com.explore.explore.entitiets.spot. Но получение этой ошибки < /p>
Type definition error: [simple type, class com.explore.explore.entities.Spot]] with root cause
Я проверил точечный класс и его зависимости, но я не могу найти проблему. Как я могу исправить эту ошибку и правильно сериализовать объект Spot на JSON? Правильно.package com.explore.explore.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.explore.explore.entities.Spot;
import com.explore.explore.services.SpotService;

@RestController
public class MyController {

@Autowired
public SpotService SpotService;

@GetMapping("/hello")
public String home() {
return "hello";
}

// get spots
@GetMapping("/spots")
// public List getSpots() {
// List list;
// list = new ArrayList();
// list.add(3);
// list.add(5);
// return this.SpotService.getSpots();
// }

public List getSpots() {

List list;
list = new ArrayList();
list.add(new Spot(1, "38 Block", "Near 38"));
list.add(new Spot(0, "UNIMAll", "Near Me"));
return list;
}
}

spot.java
package com.explore.explore.entities;

import org.springframework.http.converter.HttpMessageConversionException;

public class Spot {
private long id;
private String name;
private String location;

public Spot(long id, String name, String location) {

super();
this.id = id;
this.name = name;
this.location = location;

}
public Spot() {
super();
}
}



Подробнее здесь: https://stackoverflow.com/questions/758 ... pplication

Вернуться в «JAVA»