zoukankan      html  css  js  c++  java
  • 【日常错误】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>

    解决。

  • 出处: http://www.cnblogs.com/hiscode/
    本文版权归作者和博客园共有,转载请在文章页面明显位置标明原文链接。
查看全文
  • 相关阅读:
    java 分解质因数
    Unix 文件系统读写时权限校验
    find 命令实战巧用
    Linq分组功能
    三种查看SqlServer中数据物理pge页的方法
    一个高度压缩的bit位图字典的实现
    windbg 命令 gchandles
    ManualResetEvent和AutoResetEvent的区别实例
    一些汇编指令(基于8086)
    windbg sos版本不匹配问题解决
  • 原文地址:https://www.cnblogs.com/hiscode/p/Could_not_initialize_class_ConfigurationImpl.html
  • Copyright © 2011-2022 走看看