首页 > 解决方案 > java.lang.NoClassDefFoundError:无法初始化类 org.hibernate.validator.internal.engine.ConfigurationImpl

问题描述

我阅读了有关该问题的其他主题,例如:

无法在 Spring 工具套件中初始化类 org.hibernate.validator.internal.engine.ConfigurationImpl

Hibernate Validator java.lang.NoClassDefFoundError:无法初始化类 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)

标签: javaspringhibernatespring-boot

解决方案


我发现我必须包括 jboss:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

此错误的原因是某人过去所做的排除。


推荐阅读