1. 程式人生 > >Caused by: java.lang.NoClassDefFoundError: org/hibernate/validator/internal/engine/DefaultParameterN

Caused by: java.lang.NoClassDefFoundError: org/hibernate/validator/internal/engine/DefaultParameterN

Caused by: java.lang.NoClassDefFoundError: org/hibernate/validator/internal/engine/DefaultParameterNameProvider
at org.hibernate.validator.internal.engine.ConfigurationImpl.(ConfigurationImpl.java:128) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
at org.hibernate.validator.internal.engine.ConfigurationImpl.(ConfigurationImpl.java:96) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:31) ~[hibernate-validator-5.2.4.Final.jar:5.2.4.Final]
at javax.validation.Validation G

e n e r i c B o o t s
t r a p I m p l . c o
n f i g u r e ( V a l i d a t i o n . j a v a : 269 )   [ v a l i d a t i o n a p i 1.0.0. G A . j a r : n a ] a t o r g . s p r i n g f r a m e w o r k . v a l i d a t i o n . b e a n v a l i d a t i o n . L o c a l V a l i d a t o r F a c t o r y B e a n . a f t e r P r o p e r t i e s S e t ( L o c a l V a l i d a t o r F a c t o r y B e a n . j a v a : 248 )   [ s p r i n g c o n t e x t 4.3.4. R E L E A S E . j a r : 4.3.4. R E L E A S E ] a t o r g . s p r i n g f r a m e w o r k . b o o t . c o n t e x t . p r o p e r t i e s . C o n f i g u r a t i o n P r o p e r t i e s B i n d i n g P o s t P r o c e s s o r GenericBootstrapImpl.configure(Validation.java:269) ~[validation-api-1.0.0.GA.jar:na] at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:248) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor LocalValidatorFactory.run(ConfigurationPropertiesBindingPostProcessor.java:452) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.getValidator(ConfigurationPropertiesBindingPostProcessor.java:386) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.determineValidator(ConfigurationPropertiesBindingPostProcessor.java:369) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:331) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:302) ~[spring-boot-1.4.0.RELEASE.jar:1.4.0.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1575) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
… 52 common frames omitted

問題:
spring-boot-starter-web裡面依賴的hibernate-validator與其他的依賴衝突了,其他的依賴版本過低,但是覆蓋了springboot的依賴。
解決辦法:
剔除其他的依賴,或者直接單獨新增springboot的依賴版本覆蓋其他依賴

我這裡是這兩個依賴被覆蓋了,直接單獨新增覆蓋原本的依賴即可

	<dependency>
          <groupId>org.jboss.logging</groupId>
          <artifactId>jboss-logging</artifactId>
          <version>3.3.2.Final</version>
      </dependency>
      <dependency>
          <groupId>javax.validation</groupId>
          <artifactId>validation-api</artifactId>
          <version>1.1.0.Final</version>
      </dependency>