WebFluxConfigurer configureHttpMessageCodecs
Spring Boot 2 + Kotlin
@Configuration
@EnableWebFlux
class WebConfiguration : WebFluxConfigurer {
override fun configureHttpMessageCodecs(configurer: ServerCodecConfigurer) {
configurer.defaultCodecs().jackson2JsonEncoder(Jackson2JsonEncoder(ObjectMapper()
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)))
configurer.defaultCodecs().jackson2JsonDecoder(Jackson2JsonDecoder(ObjectMapper()
.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)))
}
}
, , /, , @JsonProperty, json-
data class MyClass(
@NotNull
@JsonProperty("id")
val id: String,
@NotNull
@JsonProperty("my_name")
val name: String)