error: No validator could be found for type: java.time.LocalDate

后端 未结 3 604
轮回少年
轮回少年 2020-12-31 08:35

I\'m working on a project that uses bean validation (Hibernate Validator 5.1.3.Final). My bean has a attribute with the @Past annotation.

@Past(         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 09:06

    Since LocalDate is still pretty new a lot of libraries don't handle it yet. In the project I am working on I had to write custom user type for LocalDate.

    Take a look at this hibernate issue HHH-8844

    It seems like they have added a new module hibernate-java8 to support java 8's new Date API.

    I know the above information is talking about type mapping but the same might hold true to validation.

    If there is no out of the box solution you might just have to write your own. See the following page for an example of adding joda time validators, java 8 dates should be similar link

提交回复
热议问题