我正在使用 spring data mongodb 运行 spring boot 2.2.5.RELEASE。在运行时,我遇到这样的错误:
org.springframework.data.mapping.MappingException:在实体类 java.time.LocalDate 上找不到要绑定构造函数参数的属性 dayOfMonth!在
这是完整的错误消息:
警告:发生了非法反射访问操作警告:org.springframework.util.ReflectionUtils 非法反射访问(文件:/home/gentur/.m2/repository/org/springframework/spring-core/5.2.4.RELEASE/spring -core-5.2.4.RELEASE.jar) 到构造函数 java.time.LocalDate(int,int,int) 警告:请考虑将此报告给 org.springframework.util.ReflectionUtils 的维护者警告:使用 --illegal-access =警告以启用对进一步非法反射访问操作的警告警告:所有非法访问操作将在未来版本中被拒绝 2021-04-17 11:25:13.168 错误 1406020 --- [nio-9191-exec-1] occC [ .[.[/].[dispatcherServlet]:Servlet.service() 用于路径 [] 上下文中的 servlet [dispatcherServlet] 引发异常 [请求处理失败;嵌套异常是 org.springframework.data.mapping。
org.springframework.data.mapping.MappingException:在实体类 java.time.LocalDate 上找不到要绑定构造函数参数的属性 dayOfMonth!在 org.springframework.data.mapping.model.PersistentEntityParameterValueProvider.getParameterValue(PersistentEntityParameterValueProvider.java:68) ~[spring-data-commons-2.2.5.RELEASE.jar:2.2.5.RELEASE] 在 org.springframework.data。 mapping.model.SpELExpressionParameterValueProvider.getParameterValue(SpELExpressionParameterValueProvider.java:49) ~[spring-data-commons-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.convert.ReflectionEntityInstantiator.createInstance(ReflectionEntityInstantiator .java:75) ~[spring-data-commons-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.convert.ClassGeneratingEntityInstantiator.createInstance(ClassGeneratingEntityInstantiator.java:
当我调用此 mongo 存储库接口时发生此错误
import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.Optional;
import com.cronostar.loyalty.domain.PromotionRule;
public interface PromotionRuleRepository extends MongoRepository<PromotionRule, String> {
public Optional<PromotionRule> findByPromotionCode(String promotionCode);
}
这是域类
public class PromotionRule implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7468271749194058161L;
private String id;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime createdAt = LocalDateTime.now();
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime modifiedAt;
private String version;
private String promotionCode;
private String promotionName;
private String description;
private Boolean active;
private String status;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate startDate;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate endDate;
private Long limitDistributedPoints;
private Long remainingDistributedPoints;
private Long minimumPaidAmount;
private Long maximumPointsPerTransaction;
private String pointExpiryType;
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate pointExpiryValue;
private String typeOfCalculatedPoints;
private Double valueOfCalculatedPoints;
private Boolean stackable;
private String applyTo;
private List<PromotionFunder> promotionFunders;
private List<PromotionCriteria> promotionCriterias;
}
我不知道这个错误,如果有人能给我这个错误的解决方案,我真的很感激。
谢谢
真图尔·维迪亚普特拉