Rom*_*sov 2 spring kotlin spring-data-jdbc
我尝试将 Spring Data JDBC 与 Kotlin 数据类一起使用,在@Transient向主构造函数添加属性后,我在简单findById调用时收到错误:
java.lang.IllegalStateException: Required property transient not found for class mitasov.test_spring_data_with_kotlin.Entity!
Run Code Online (Sandbox Code Playgroud)
我的实体类如下所示:
java.lang.IllegalStateException: Required property transient not found for class mitasov.test_spring_data_with_kotlin.Entity!
Run Code Online (Sandbox Code Playgroud)
读完该问题后,我尝试@PersistenseConstructor在没有@Transient字段的情况下进行:
data class Entity(
@Id
var id: String,
var entityName: String,
@Transient
var transient: List<TransientEntity>? = mutableListOf(),
)
Run Code Online (Sandbox Code Playgroud)
但这对我没有帮助,而且我仍然收到该错误。
我怎么解决这个问题?
事实证明,我的第二次尝试就是解决方案。
\n诀窍在于我的测试运行/调试配置。
\n在 IDEA 首选项中,我选中了Preferences | Build, Execution, Deployment | Build Tools | Maven | Runner \xe2\x80\x94 Delegate IDE build/run actions to Maven复选框,这意味着我需要在运行测试之前手动重新编译我的项目。
所以,这就是错误的解决方案
\njava.lang.IllegalStateException: Required property transient not found for class mitasov.test_spring_data_with_kotlin.Entity!\nRun Code Online (Sandbox Code Playgroud)\n正在制作@PersistenseConstructor没有@Transient字段:
java.lang.IllegalStateException: Required property transient not found for class mitasov.test_spring_data_with_kotlin.Entity!\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
2286 次 |
| 最近记录: |