本文介绍了javax.validation.ValidationException:HV000183:无法加载'javax.el.ExpressionFactory'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试用hibernate验证器编写非常简单的应用程序:
我的步骤:
添加以下依赖项在pom.xml中:
添加到 pom.xml 下面的依赖项后工作:
<依赖性>
< groupId> javax.el< / groupId>
< artifactId> javax.el-api< / artifactId>
< version> 2.2.4< / version>
< /依赖关系>
< dependency>
< groupId> org.glassfish.web< / groupId>
< artifactId> javax.el< / artifactId>
< version> 2.2.4< / version>
< /依赖关系>
I try to write very simple application with hibernate validator:
my steps:
add following dependency in pom.xml:
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.1.1.Final</version> </dependency>write code:
class Configuration { Range(min=1,max=100) int threadNumber; //... public static void main(String[] args) { ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); Validator validator = factory.getValidator(); Configuration configuration = new Configuration(); configuration.threadNumber = 12; //... Set<ConstraintViolation<Configuration>> constraintViolations = validator.validate(configuration); System.out.println(constraintViolations); } }And I gets following stacktrace:
Exception in thread "main" javax.validation.ValidationException: Unable to instantiate Configuration. at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:279) at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:110) ... at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:110) at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:86) at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:41) at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:276) ... 2 moreWhat do I wrong?
解决方案It is working after adding to pom.xml following dependencies:
<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>Getting started with Hibernate Validator
这篇关于javax.validation.ValidationException:HV000183:无法加载'javax.el.ExpressionFactory'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!