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:
Use the jackson-databind-json-format-module
dependency: Add this dependency to your pom.xml
file or Gradle build file.
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;
}
@Bean
public Decoder feignDecoder() {
return new JacksonDecoder(objectMapper());
}
@Bean
public Encoder feignEncoder() {
return new JacksonEncoder(objectMapper());
}
./mvnw clean package -DskipTests -Pnative
./target/{application-name}
Where {application-name}
is the name of your Spring Boot application.