zoukankan      html  css  js  c++  java
  • SpringBoot项目启动报错解决记录

    2020-06-29 11:14:37,181 - [WARN] o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'xxTmpRepository' defined in null: Cannot register bean definition [Root bean: class [org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'xxTmpRepository': There is already [Root bean: class [org.springframework.data.jdbc.repository.support.JdbcRepositoryFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
    2020-06-29 11:14:37,196 - [ERROR] o.s.b.d.LoggingFailureAnalysisReporter -

    ***************************
    APPLICATION FAILED TO START
    ***************************

    Description:

    The bean 'xxTmpRepository', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.

    Action:

    Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

    上面是启动报错的日志输出,总之就是说有一个类声明已经存在了,你又没说可以覆盖,所以我就报错咯。

    解决方案有两个:

    1. 像上面说的那个,给配置文件添加一个 spring.main.allow-bean-definition-overriding=true 就可以了。

    2. 找到为啥会重复,然后把重复的去掉。

    上面的日志输出已经说了是 BeanDefinitionOverrideException 抛出来的 JpaRepositoryFactoryBean 与 JdbcRepositoryFactoryBean 冲突,也就是说这两个 BeanFactory 都尝试把 xxTmpRepository 进行处理,后面处理的那个就报错了。

    不让后面那处理就可以了,我这里这个 xxTmpRepository 是 JPA的 repository,按理说 jdbcRepository 不应该去管这个,谁知道咋回事儿呢?反正就是 jdbc越权了,需要限制一下下。

    安排!把 xxTmpRepository  所在的目录不让 jdbcRepository 扫描到。

    @EnableJdbcRepositories(excludeFilters = {
            @ComponentScan.Filter(
                    type = FilterType.ASPECTJ,
                    pattern = "com.xx.xxx.repotory.*")
    })

    把这个加到主启动类上就可以了。

    完结。

  • 相关阅读:
    【笔记】二进制文件
    vs2015+64位win10系统ceres-solver编译
    python
    感受函数式编程-scala
    R语言diagram包画订单状态流图
    virtualbox下Centos6.5桥接模式上网配置方法
    配置对IIS上tabular的 HTTP 访问
    centos6.5下逻辑卷操作
    centos6.5下磁盘创建交换分区
    centos6.5下磁盘分区及挂载
  • 原文地址:https://www.cnblogs.com/kischn/p/13207028.html
Copyright © 2011-2022 走看看