hibernate-validator组件版本选择(java 1.7)

曾遇到的问题

javax.validation.ValidationException: HV000183: Unable to load ‘javax.el.ExpressionFactory’

解决方案参考

https://stackoverflow.com/questions/24386771/javax-validation-validationexception-hv000183-unable-to-load-javax-el-express

梳理一下使用官方组件的科学方式

1.从官网hibernate.org查询组件对java的依赖

http://hibernate.org/orm/documentation/getting-started/
image.png
可知,5.2和高于5.2版本的hibernate-validator需要java 1.8

2.找到低于5.2的可用版本及使用方式

https://sourceforge.net/projects/hibernate/files/hibernate-validator/5.1.0.Final/
image.png

引用自官网简介,5.1.0.Final版本的组件使用方式如下:
Add the following to your Maven or Ivy dependency list (Hibernate Validator can be found in the JBoss Maven repository):

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>5.1.0.Final</version>
    </dependency>

You also need an API and implementation of the Unified Expression Language. These dependencies must be explicitly added in an SE environment. In an EE environment they are often already provided.

    <dependency>
       <groupId>javax.el</groupId>
       <artifactId>javax.el-api</artifactId>
       <version>2.2.4</version>
    </dependency>
    <dependency>
       <groupId>org.glassfish.web</groupId>
       <artifactId>javax.el</artifactId>
       <version>2.2.4</version>
    </dependency>

Bean Validation defines integration points with CDI. If your application runs in an environment which does not provide this integration out of the box, you may use the Hibernate Validator CDI portable extension by adding the following dependency:

   <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator-cdi</artifactId>
      <version>5.1.0.Final</version>
   </dependency>
3.了解[JSR-349 - Bean Validation 1.1]规范

上一步5.1.0.Final页面链接如下:
https://beanvalidation.org/1.1/
image.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值