springboot-data-elasticsearch踩坑---@Id注解引入錯誤
在項目中引入springboot-data的elasticsearch后, 寫了一個實體類, 類里面定義了一個id, 同時用了@Id標注該屬性為ES里面的ID
結果啟動的時候發現console里面報了一個warnning:
wanning log:
2022-07-01 16:56:24.266 WARN 34008 --- [ main] .m.SimpleElasticsearchPersistentProperty : Using the property name of 'id' to identify the id property is deprecated. Please annotate the id property with '@Id'
解決方式: 檢查@Id注解是不是導錯包了

進入SimpleElasticsearchPersistentProperty 這個類里面定位到報異常的地方

可以看到打這個warnning日志的地方是由isIdWithoutAnnotation控制的, 但是明明加了@Id的注解為什么沒匹配到呢?
然后看下Id.class是哪個包的Id注解, 結果發現導錯包了
要用這個包里面的@Id注解: package org.springframework.data.annotation;
結果導成了 javax.persistence.Id
本文來自博客園,作者:你啊347,轉載請注明原文鏈接:http://www.rzrgm.cn/LinKinSJ/p/16435307.html

浙公網安備 33010602011771號