Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.