我想将 QueryByExampleExecutor 与 ElasticsearchRepository 一起使用,但在构建 SpringBootApplication 时出现异常。我正在使用具有以下依赖项的 Gradle:
springboot 2.2.4.RELEASE
spring-boot-starter-data-elasticsearch
我的存储库:
@Repository
public interface OrdersRepository extends ElasticsearchRepository<Orders, String>,
QueryByExampleExecutor {
Page<Orders> findByCustomerFirstNameIgnoreCase(String customerFirstName, Pageable pageable);
Page<Orders> findByCustomerLastNameIgnoreCase(String customerLastName, Pageable pageable);
Page<Orders> findByOrderNo(Long orderNo, Pageable pageable);
}
我在其中使用示例查询实现方法的控制器:
@PostMapping("search/any")
public Iterable<Orders> searchByAnyText
(@RequestBody Orders orders) {
final Example<Orders> ordersExample = Example.of(orders);
return repo.findAll(ordersExample);
}
这是我的订单类:
@JsonIgnoreProperties(ignoreUnknown = true)
@Data
@Document(indexName = "#{@indexName}",
type = "#{@typeName}")
public class Orders {
@Id
private String orderHeaderKey;
@Version
private Long createdAt;
private Long updatedAt;
private String createuserid;
private String allAddressesVerified;
private String modifyuserid;
private String customerZipCode;
private String customerFirstName;
private String orderType;
@Field(type = FieldType.Object)
private PersonInfoBillTo personInfoBillTo;
@Field(type = FieldType.Object)
private List<OrderDate> orderDates;
private String minOrderStatus;
private String multipleStatusesExist;
private String sourceIPAddress;
private String hasDeliveryLines;
private String minOrderStatusDesc;
private String returnByGiftRecipient;
private String enterpriseCode;
private String paymentStatus;
private String taxExemptionCertificate;
private String status;
private String taxPayerId;
private String hasProductLines;
@Field(type = FieldType.Object)
private List<OrderLine> orderLines;
private String hasServiceLines;
private String customerEMailID;
private String notificationType;
private String sellerOrganizationCode;
private String createts;
private String orderName;
private String billToKey;
private Long orderNo;
private String searchCriteria1;
private String originalTotalAmount;
private String searchCriteria2;
private String maxOrderStatus;
private String draftOrderFlag;
private String enteredBy;
private String processPaymentOnReturnOrder;
private String customerPhoneNo;
private String hasDerivedChild;
private String noOfAuthStrikes;
private String documentType;
private String purpose;
private String maxOrderStatusDesc;
private String customerPONo;
private String hasPendingChanges;
private String orderDate;
private String customerRewardsNo;
private String entryType;
private String modifyts;
private String orderComplete;
private String customerLastName;
private String notificationReference;
private String allocationRuleID;
private String paymentRuleId;
private String billToID;
private String holdFlag;
private String overallStatus;
}
我在运行应用程序时遇到异常(粘贴部分异常):
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ordersRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property exists found for type Orders!
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1796) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
.
.
. ... 19 common frames omitted
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property exists found for type Orders!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:94) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:311) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
at java.util.concurrent.ConcurrentMap.computeIfAbsent(ConcurrentMap.java:324) ~[na:1.8.0_221]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:293) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:276) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]