Fcser 2019-12-09 16:15 采纳率: 100%
浏览 1709
已结题

springboot启动加载Converter报错

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"));
}

  • 写回答

3条回答 默认 最新

  • antumbra 2019-12-09 16:44
    关注

    应该是无法获取参数:DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")的数据类型导致的,这是个实例化后才能用的方法,这样写得不到它返回的结果值的

    评论

报告相同问题?