Case
Jackson, which was declared in the application (YAML/properties), but didn't apply to the Client HttpMessageConverter in Spring Boot 4.0.1
Code:
...
implementation("org.springframework.boot:spring-boot-starter-jackson")
implementation("org.springframework.boot:spring-boot-http-converter")
...
implementation("org.springframework.cloud:spring-cloud-starter-openfeign")
...
implementation("tools.jackson.module:jackson-module-kotlin")
...
jackson:
datatype:
enum:
read_unknown_enum_values_using_default_value: true
deserialization:
fail_on_unknown_properties: false
fail_on_null_for_primitives: false
use_big_decimal_for_floats: true
json:
read:
allow_java_comments: true
@FeignClient(
name = "TestFeignClient",
url = "\${application.test.host}",
)
interface TestFeignClient {
@PostMapping("/query")
fun getResponse(request: TestRequest): TestResponse
}
...
data class TestResponse(
...
enum class Status {
@JsonAlias("a")
A,
@JsonEnumDefaultValue
O,
}
...
)
Error:
Caused by: org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `TestResponse$Status` from String "new": not one of the values accepted for Enum class: [O, A, a]
Info
It works correctly in Spring Boot 4.0.0
Read the #48574 document, but it's not clear to me whether, in my case, I also still need to introduce ClientHttpMessageConvertersCustomizer and set it manually from JsonMapper, which is instantiated by Spring Boot.
Case
Jackson, which was declared in the application (YAML/properties), but didn't apply to the Client HttpMessageConverter in
Spring Boot 4.0.1Code:
@FeignClient( name = "TestFeignClient", url = "\${application.test.host}", ) interface TestFeignClient { @PostMapping("/query") fun getResponse(request: TestRequest): TestResponse } ... data class TestResponse( ... enum class Status { @JsonAlias("a") A, @JsonEnumDefaultValue O, } ... )Error:
Info
It works correctly in
Spring Boot 4.0.0Read the #48574 document, but it's not clear to me whether, in my case, I also still need to introduce
ClientHttpMessageConvertersCustomizerand set it manually fromJsonMapper, which is instantiated by Spring Boot.