spring-boot - 带有 kotlin 的 Spring Data Redis 在 2.3.2.RELEASE 版本中中断
问题描述
将 Spring Boot 从 2.3.0 迁移到 2.3.2.RELEASE 后,我的 @RedisHash 代码已损坏。
@RedisHash(value = "OtpCache", timeToLive = 5 * 60)
data class OtpCache(@Id val mobile: String,
val otp: String)
interface OtpCacheRepository : CrudRepository<OtpCache, String>
val optional = otpCacheRepository.findById("unknown")
println("optional = " + optional.isPresent)
当我尝试使用 查找具有未知标识符的 OtpCache 实例findById
而不是获取 Optional.empty() 时,我看到了一个异常
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method com.example.demo.OtpCache.<init>, parameter mobile
at com.example.demo.OtpCache.<init>(DemoApplication.kt) ~[main/:na]
at com.example.demo.OtpCache_Instantiator_humu2e.newInstance(Unknown Source) ~[main/:na]
at org.springframework.data.mapping.model.ClassGeneratingEntityInstantiator$EntityInstantiatorAdapter.createInstance(ClassGeneratingEntityInstantiator.java:238) ~[spring-data-commons-2.3.2.RELEASE.jar:2.3.2.RELEASE]
这段代码在 Spring Boot 中运行良好2.3.0.RELEASE
我正在使用 Kotlin 数据类在我的代码库中创建 POJO。
这是示例存储库的链接
解决方案
推荐阅读
- javascript - 使用 react 渲染书架
- android - Jetpack Compose - 我的 Text() 中的版式自定义不受影响
- javascript - 将对象数组聚合成一个对象
- android - handshakeexception 客户端中的握手错误(os error wrong_version_number tls_record cc 242) Flutter 应用程序/节点服务器
- javascript - TypeError:a.preventDefault 不是函数
- git - git lab cicd 文件的内容只是做一个简单的拉
- multiprocessing - 由于 IPython 和 Windows 的限制,python 多处理现在不可用。所以将`number_workers`改为0以避免卡住
- javascript - 如何防止特定路由的中间件
- c# - 如何使用 API 在 google map xamarin iOS 上更新 PIN 中的信息
- java - dockerise后Tomcat服务器无法与Postman连接