【问题标题】:No property customize found for type with QuerydslBinderCustomizer in Kotlin在 Kotlin 中找不到使用 QuerydslBinderCustomizer 的类型的属性自定义
【发布时间】:2020-09-13 20:20:56
【问题描述】:

我有一个 CRUD 应用,使用 Kotlin 中的 Spring REST 数据创建。

@Repository
interface OrderRepository : PagingAndSortingRepository<Order, Long>, QuerydslPredicateExecutor<Order>, QuerydslBinderCustomizer<QOrder> {

    override fun customize(bindings: QuerydslBindings, root: QOrder) {
        bindings.bind(root.address.name)
                .first(StringExpression::containsIgnoreCase)
    }
}

我已经自定义了我的 QuerydslPredicateExecutor,根据一些示例,当我运行上述应用程序时,我从 Spring 收到一个初始化错误,上面写着:

org.springframework.data.mapping.PropertyReferenceException: No property customize found for type Order!

我认为这可能是 Kotlin 的问题,可能它没有按照 Spring 的预期进行编译,现在正在尝试创建一个新的数据访问函数,而不是仅仅自定义 QueryDSLBinder?

【问题讨论】:

    标签: spring kotlin spring-data


    【解决方案1】:

    可能的解决方案

    在该方法上使用 Kotlin 的实验性 @JvmDefault 注释将解决此问题。

    @JvmDefault
    override fun customize(bindings: QuerydslBindings, root: QOrder) {
        bindings.bind(root.address.name)
            .first(StringExpression::containsIgnoreCase)
    }
    

    需要注意的是需要在编译器args中加上-Xjvm-default=enable

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-22
      • 2017-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多