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

 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
2017-11-01 16:45:20.206 INFO 14252 --- [ main] utoConfigurationReportLoggingInitializer : Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
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>

解决。

最新文章

  1. java实现甘特图的2种方法:SwiftGantt和Jfree (转)
  2. patchca验证码的使用
  3. 怎么用ABBYY创建属于自己的PDF
  4. hdu 3046 Pleasant sheep and big big wolf 最小割
  5. PHP取二进制文件头快速判断文件类型
  6. AnimateWindow 阻塞当前线程问题
  7. maven自动部署到tomcat的问题
  8. FTP下载帮助类
  9. day23 框架之基础加强
  10. 结构体struct sockaddr_in, struct sockaddr,struct in_addr
  11. centos7下安装mysql5.7.17
  12. Sublime 3基于python环境的使用
  13. docker_flannel
  14. 阿里云-AliRepo
  15. spring boot(二): spring boot+jdbctemplate+sql server
  16. 通过DbVisualizer 工具运行DB2存储过程实现INSERT语句主键自增造数
  17. synchronized(八)
  18. 谈话准备.xmind 思维导图模版
  19. java基础四 基本语法
  20. ReportNG测试报告的定制修改(二)

热门文章

  1. Pandas | 17 缺失数据处理
  2. [springboot 开发单体web shop] 1. 前言介绍和环境搭建
  3. Element-ui-安装
  4. js取两位小数点
  5. CF480E Parking Lot(单调队列+dp然鹅并不是优化)
  6. [转载]1.4 UiPath参数的介绍和使用
  7. .NET进阶篇06-async异步、thread多线程2
  8. 【Elasticsearch 7 探索之路】(三)倒排索引
  9. requests模块发送带headers的Get请求和带参数的请求
  10. ArcGIS API For Javascript:新增热力图层的方法