java - java.lang.NoClassDefFoundError:无法初始化类 org.hibernate.validator.internal.engine.ConfigurationImpl
问题描述
我阅读了有关该问题的其他主题,例如:
无法在 Spring 工具套件中初始化类 org.hibernate.validator.internal.engine.ConfigurationImpl
但他们没有帮助我。
在外部库中,我只有 Hibernate-validator(6.0.10 版本)。我在所有 pom 中使用 SpringBoot 2.0.3。我设置:
<properties>
<cxf.version>3.2.4</cxf.version>
<cxf.xjc.version>3.2.1</cxf.xjc.version>
<spring.oxm.version>4.2.4.RELEASE</spring.oxm.version>
<aspectj.version>1.8.10</aspectj.version>
</properties>
cxf 3.2.4 来自 2018 年 3 月。cxf.xjc 来自 2018 年 2 月。Hibernate-validator 来自
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
我也排除了jboss-logging
:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
在我的外部库中,我只有 javax.validation-api 2.0.1.final,建议在此处休眠 6.0.13: https ://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single /#validator-gettingstarted-createproject
我在类中的构造函数上设置了断点,ConfigurationImpl
但是当我在 tomcat 9.0.12 上运行应用程序时它不会触发(不是业务需求的 springboot 原因)。
错误是:
Caused by: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration': Unsatisfied dependency expressed through field 'properties'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cxf-org.apache.cxf.spring.boot.autoconfigure.CxfProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:155)
解决方案
我发现我必须包括 jboss:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
此错误的原因是某人过去所做的排除。
推荐阅读
- java - Spring Batch - 作业未启动,因为 ORA-14400:插入的分区键未映射到任何分区
- amazon-web-services - AWS CLI 不会检测/接受凭证
- asp.net-core - 更改安全印章
- excel - 查找双精度值
- postgresql - 在基于 postgres 数据库的数据仓库中实现继承的最佳方法
- spring-boot - Spring-boot:原型范围bean:如何检查具有相同值的bean是否已经存在?
- javascript - 如何在 React 的 UseEffect() 中调用异步函数?
- vba - VBA 中的 Windows 键盘挂钩 API 导致 PowerPoint 中的无限循环
- python - AWS Lambda,Python:获取具有启动时间的实例以进行排序语法错误,比较标签时出错
- java - 来自覆盆子的 jaydebeapi 的问题类路径