• 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;
    导致报错
  • 相关阅读:
    Tensorflow入门:Linear Regression
    日语动词变形总结
    序列模型第二周作业2:Emojify!
    序列模型第二周作业1:Operations on word vectors
    序列模型第一周作业3: Improvise a Jazz Solo with an LSTM Network
    序列模型第一周作业2: Character level language model
    序列模型第一周作业1: Building your Recurrent Neural Network
    Bidirectional RNN (BRNN)
    Long Short term memory unit(LSTM)
    propertyGrid使用
  • 原文地址:https://www.cnblogs.com/javawxid/p/10966814.html
Copyright © 2020-2023  润新知