[英]org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type Account to type AllAccount
[英]org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type Model
这是存储库方法,您将看到通过 created_date 从 UserDetail 实体表中选择列,但是当我输入 swagger 这个值时出现错误 2021-10-14 23:16:31
@Query(value = "SELECT usd.phoneNumber,usd.textMessage FROM UserDetail entity usd WHERE usd.created_date=:createdDate", nativeQuery = true)
UserDetail findByCreatedDate(LocalDateTime createdDate);
我尝试在服务层输入参数字符串格式并转换为 LocalDate 时间,如下代码:
@Override
public UserDetail findByCreatedDateWhenUserTypeOwnInfo(String createdDate) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime dateTime = LocalDateTime.parse(createdDate, formatter);
return this.userDetailRepository.findByCreatedDate(dateTime);
}
我收到此错误:
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [az.expressbank.expressbankproject.data.model.UserDetail]
如何解决这个问题>?
您正在使用“命名参数”,因此看起来您需要将 @Param 添加到您的查询中。 像这样:
UserDetail findByCreatedDate(@Param("createdDate") LocalDateTime createdDate);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.