java写了一个string转LocalDateTime的Converter的方法,但是springboot启动报错:
Caused by: java.lang.IllegalArgumentException: Unable to determine source type and target type for your Converter [com.example.demo126.config.MappingConverterAdapter$$Lambda$522/1340928776]; does the class parameterize those types?
代码如下:
/**
* 日期参数接收转换器,将json字符串转为日期类型
*
* @return Converter
*/
@Bean
public Converter localDateTimeConverter() {
return source -> LocalDateTime.parse((String)source, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}