Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

287
Vistas
SpringBoot MongoDB returns "Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable"

I tried adding a new collection to my API/DB today, and when I try to POST or GET, I get this 500 error response:

{
  "cause": null,
  "message": "Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable"
}

However the POST is actually successful, I can see the new data in the DB.

Model:

@Setter
@Getter
public class League {

    private String name;
    private String shortName;
    private List<Team> teams;
}

Repository:

@RepositoryRestResource(collectionResourceRel = "leagues", path = "leagues", excerptProjection = LeagueProjection.class)
public interface LeagueRepository extends MongoRepository<League, String> {

}

Projection:

@Projection(name="LeagueProjection", types={League.class})
public interface LeagueProjection {

    String getName();
    String getShortName();
}

I am not doing anything special. I have multiple other collections that work fine.

I am using spring-boot 1.5.1.

Thanks!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Adding the field:

@Id private String id;

to my model seems to have resolved the issue.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda