elasticsearch查询:启动项目报错No property ... found for...Did you mean '...'?
2024-09-01 14:28:22
网上找的案例是:
实体类字段定义:
private String sku_no;
dao中接口名定义:
Goods findBySkuNo(String skuNo);
spring-data按照接口方法定义的名字(默认认为是驼峰写法)skuNo去实体类查找对应字段,当找不到时,就报错了:
org.springframework.data.mapping.PropertyReferenceException: No property skuNo found for type Goods! Did you mean 'sku_no'?
spring-data规范要求dao中的findBy***,必须和实体字段名称一致,例如findByUdateTime,实体中也要是private String udateTime; 实体字段命名不能是sku_no这种格式,这个不符合驼峰规范。
我项目启动报错No property name found for EsProduct
因为findByNameOrSubTitleOrKeywords接口没有使用也没有注释掉,改了实体类
/**
* 商品ES操作类
* Created by macro on 2018/6/19.
*/
public interface EsProductRepository extends ElasticsearchRepository<EsProduct, Long> {
/**
* 搜索查询
*
* @param name 商品名称
* @param subTitle 商品标题
* @param keywords 商品关键字
* @param page 分页信息
* @return
*/
Page<EsProduct> findByNameOrSubTitleOrKeywords(String name, String subTitle, String keywords,Pageable page);
}
而我的EsProduct实体类中没有name
/**
* 搜索中的商品信息
* Created by macro on 2018/6/19.
*/
@Document(indexName = "pms", type = "product",shards = 1,replicas = 0)
public class EsProduct implements Serializable {
private static final long serialVersionUID = -1L;
@Id
private Long id;
@Field(type = FieldType.Keyword)
private String productSn;
private Long brandId;
@Field(type = FieldType.Keyword)
private String brandName;
private Long productCategoryId;
@Field(analyzer = "ik_max_word",type = FieldType.Text)
private String productName;
@Field(analyzer = "ik_max_word",type = FieldType.Text)
private String subTitle;
private BigDecimal price;
@Field(analyzer = "ik_max_word",type = FieldType.Text)
private String keywords; @Field(type =FieldType.Nested)
private List<EsProductAttribute> attriList; @Field(type =FieldType.Nested)
private EsProductCategory productCategorie;
导致报错
最新文章
- Endnote专题之--output style相关问题
- TCP\IP三次握手连接,四次握手断开分析
- http协议(五)web服务器
- CPU cache
- Java源码初学_HashSet&;LinkedHashSet
- UVa 10054 (打印欧拉回路) The Necklace
- ural2014 Zhenya moves from parents
- jqGrid添加自定义按钮
- 36.java_exception_test
- Rxjava学习小记
- scrapy初试
- C++反汇编第五讲,认识多重继承,菱形继承的内存结构,以及反汇编中的表现形式.
- php中的echo,json_decode,json_encode常用函数使用注意事项
- Latex基础__如何用latex编写矩阵、矩阵等式、方程组、等式左对齐
- HybridStart发布v1.0测试版
- centos下载
- dismiss 多个viewController
- CloudSim源代码学习——云数据中心(Datacenter)
- 洗礼灵魂,修炼python(31)--面向对象编程(1)—面向对象,对象,类的了解
- .NET:C# 如何实现的闭包?