运行Spring Boot应用程序时如何解决java.lang.NoClassDefFoundError:com / fasterxml / classmate / TypeResolver

时间:2019-07-19 06:17:46

标签: spring spring-boot keycloak spring-framework-beans

我正在尝试运行一个与keycloak集成的示例应用程序(用于IAM)。 构建成功,但是在运行应用程序时,出现以下错误...

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-07-19 11:30:28.660 ERROR 103440 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultValidator' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/fasterxml/classmate/TypeResolver
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1708) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]

at org.keycloak.quickstarts.devconf2019.app.CarsApp.main(CarsApp.java:38) [classes/:na]
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/classmate/TypeResolver


我添加了com.fasterxml.jackson.core(2.9.5)和com.fasterxml(1.3.1)作为依赖项。 Springboot版本是-2.0.3.RELEASE

是否存在带有fastxml依赖项的版本兼容性问题?如何找到缺少的依赖关系并解决这个问题?

1 个答案:

答案 0 :(得分:1)

您需要添加 hibernate-validator 依赖项,它与捆绑在其中的 com.fasterxml:classmate 一起提供。

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