Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

110
Visualizações
Individual Serializer in Springframework

I use springframeworks in my project and for JSON we use jackson. One list should be serialized in a specific way, i.e. should have a specific JSON-output. I followed the answers of this thread but this fails.

@JsonSerialize(using = UserDataSerializer.class)
List<TestObj> lstTest;

and

public class UserDataSerializer extends StdSerializer<TestObj> {

    protected UserDataSerializer(Class<TestObj> t) {
        super(t);
    }

    @Override
    public void serialize(TestObj value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        gen.writeStartObject();
        gen.writeObjectField(value.getName(), value.getValue());
        gen.writeEndObject();
    }
}

but unfortunately this approach fails with an exception:

Servlet.service() for servlet [test3backend] in context with path [/test] threw exception [Request processing failed; nested exception is org.springframework.beans.f
actory.UnsatisfiedDependencyException: Error creating bean with name 'me.test.entities.UserDataSerializer': Unsatisfied dependency expressed through constructor paramete
r 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.Class<me.test.entities.TestObj>' av
ailable: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}] with root cause
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.Class<at.me.test.entities.TestObj>' available: expected at leas
t 1 bean which qualifies as autowire candidate. Dependency annotations: {}

Any hints how to properly configure it in my project?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The main problem with this issue was that I did not include a default null constructor, i.e. adding

public UserDataSerializer() {
    this(null);
}

solved this issue.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda