【日常错误】Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl...

最近在用spring-boot编写一个Lucene项目,中间用到了redis,引用了spring-boot-starter-data-redis,在eclipse中用外部Tomcat启动项目一切正常,但是在运行Junit测试用例或使用spring-boot的application的main方法启动项目时,会报如下错误:

1 2017-11-01 16:45:20.166  WARN 14252 --- [           main] o.s.w.c.s.GenericWebApplicationContext   : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'buildController': Unsatisfied dependency expressed through field 'redisTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisConfig': Unsatisfied dependency expressed through field 'redisConnectionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration$RedisConnectionConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'spring.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
2 2017-11-01 16:45:20.206  INFO 14252 --- [           main] utoConfigurationReportLoggingInitializer : 
3 
4 Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
5 2017-11-01 16:45:20.230 ERROR 14252 --- [           main] o.s.boot.SpringApplication               : Application startup failed

搜索堆栈中错误信息,很多博客都说是  hibernate-validator  版本冲突的问题:

http://www.jianshu.com/p/a33518f4012f

https://howtodoinjava.com/spring/spring-mvc/solved-java-lang-noclassdeffounderror-could-not-initialize-class-org-hibernate-validator-engine-configurationimpl/

于是尝试在pom文件中exclude排除spring-boot中自带的这个jar包:

在pom.xml代码里的配置变为如下:

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-validator</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

解决。

转载于:https://www.cnblogs.com/hiscode/p/Could_not_initialize_class_ConfigurationImpl.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值