zoukankan      html  css  js  c++  java
  • elasticsearch查询:启动项目报错No property ... found for...Did you mean '...'?

    网上找的案例是:

    实体类字段定义:
    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;
    导致报错
  • 相关阅读:
    Python内置函数 __import__ 动态加载模块
    Django_静态资源配置和ajax(九)
    GO语言学习(五)Go 语言基础语法
    GO语言学习(四)GO语言语言结构
    GO语言学习(三)GO语言学习API文档
    GO语言学习(二)Windows 平台下 LiteIDE 的安装和使用
    GO语言学习(一)Windows 平台下 Go 语言的安装和环境变量设置
    VS无法访问IIS元数据库 您没有足够的特权访问计算机上的IIS网站
    本地存储localStorage以及它的封装接口store.js的使用
    操作类封装
  • 原文地址:https://www.cnblogs.com/javawxid/p/10966814.html
Copyright © 2011-2022 走看看