Ask Your Question
3

How can the serialization and deserialization issue of Feign Client Jackson be addressed in Spring Boot 3 native image?

asked 2022-01-26 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-08-14 22:00:00 +0000

david gravatar image

The serialization and deserialization issue of Feign Client Jackson can be addressed in Spring Boot 3 native image by following these steps:

  1. Use the jackson-databind-json-format-module dependency: Add this dependency to your pom.xml file or Gradle build file.

  2. Configure the serialization and deserialization features: Configure the serialization and deserialization features by adding the following code to your Spring Boot application configuration class:

@Bean
public ObjectMapper objectMapper() {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    return objectMapper;
}
  1. Configure Feign Client to use Jackson: Configure Feign Client to use Jackson by adding the following code to your Spring Boot application configuration class:
@Bean
public Decoder feignDecoder() {
    return new JacksonDecoder(objectMapper());
}

@Bean
public Encoder feignEncoder() {
    return new JacksonEncoder(objectMapper());
}
  1. Build the native image with GraalVM: Build the native image with GraalVM by running the following command:
./mvnw clean package -DskipTests -Pnative
  1. Run the Spring Boot application with the native image: Run the Spring Boot application with the native image by running the following command:
./target/{application-name}

Where {application-name} is the name of your Spring Boot application.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-01-26 11:00:00 +0000

Seen: 12 times

Last updated: Aug 14 '21