我今天尝试向我的 API/DB 添加一个新集合,当我尝试 POST 或 GET 时,我收到以下 500 错误响应:
{
"cause": null,
"message": "Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable"
}
但是 POST 实际上是成功的,我可以在数据库中看到新数据。
型号:
@Setter
@Getter
public class League {
private String name;
private String shortName;
private List<Team> teams;
}
存储库:
@RepositoryRestResource(collectionResourceRel = "leagues", path = "leagues", excerptProjection = LeagueProjection.class)
public interface LeagueRepository extends MongoRepository<League, String> {
}
投影:
@Projection(name="LeagueProjection", types={League.class})
public interface LeagueProjection {
String getName();
String getShortName();
}
我没有做任何特别的事情。我有多个其他可以正常工作的集合。
我正在使用 spring-boot 1.5.1。
谢谢!