Hi,
Having these pieces of code, tried to upgrade from Spring boot 2.X to 3.0
Controller:
@Slf4j
@RestController
public class MyController {
@RequestMapping("/cc/query/{breakdown}")
public Mono<QueryResult> getBreakdown(@PathVariable String breakdown, QueryParams queryParams) {
And the POJO container of the request parameters:
import org.joda.time.LocalDateTime;
@Data
public class QueryParams {
@NotBlank
@DateTimeFormat(pattern = "YYYYMMddHHmmss")
private LocalDateTime from;
}
This works well with Spring boot 2.7.6 but crashes with Spring boot 3.0:
DefaultHandlerExceptionResolver : Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors<EOL>Field error in object 'queryParams' on field 'from': rejected value [20221001000000]; codes [typeMismatch.queryParams.from,typeMismatch.from,typeMismatch.org.joda.time.LocalDateTime,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [queryParams.from,from]; arguments []; default message [from]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'org.joda.time.LocalDateTime' for property 'from'; Cannot convert value of type 'java.lang.String' to required type 'org.joda.time.LocalDateTime' for property 'from': no matching editors or conversion strategy found]]
Comment From: wilkinsona
Support for Joda Time has been removed in the latest major release of spring Data. This is also covered in the Spring Data release notes. Please use the equivalent java.time classes instead.