• springboot 解决 The bean 'userRepository', defined in null, could not be registered. A bean with that name has already been defined in file XXX and overriding is disabled.


    1、springboot 启动时报错:

    2019-02-20 14:59:58.226  INFO 10092 --- [           main] c.f.s.SpringbootssmApplication           : Starting SpringbootssmApplication on DESKTOP-CI9APH3 with PID 10092 (C:MyWorkworkspace_ideaspringbootssm	argetclasses started by panchanggui in C:MyWorkworkspace_ideaspringbootssm)
    2019-02-20 14:59:58.230  INFO 10092 --- [           main] c.f.s.SpringbootssmApplication           : No active profile set, falling back to default profiles: default
    2019-02-20 14:59:59.155  INFO 10092 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
    2019-02-20 14:59:59.229  WARN 10092 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'userRepository' 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 'userRepository': There is already [Generic bean: class [org.mybatis.spring.mapper.MapperFactoryBean]; scope=singleton; abstract=false; lazyInit=false; autowireMode=2; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [C:MyWorkworkspace_ideaspringbootssm	argetclassescomfantasyspringbootssmmapperUserRepository.class]] bound.
    2019-02-20 14:59:59.236  INFO 10092 --- [           main] ConditionEvaluationReportLoggingListener : 
    
    Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
    2019-02-20 14:59:59.238 ERROR 10092 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
    
    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    The bean 'userRepository', defined in null, could not be registered. A bean with that name has already been defined in file [C:MyWorkworkspace_ideaspringbootssm	argetclassescomfantasyspringbootssmmapperUserRepository.class] and overriding is disabled.
    
    Action:
    
    Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
    
    
    Process finished with exit code 1

    2、解决办法:

    在配置文件中添加:

    spring.main.allow-bean-definition-overriding=true

    
    
    
  • 相关阅读:
    <转> 解决异常:IllegalStateException: Fragment <ThisFragment> is not currently in the FragmentManager
    带你走进Android Afinal框架的世界
    Android滑动菜单特效实现,仿人人客户端侧滑效果,史上最简单的侧滑实现
    Myeclipse启动不了的解决方法
    select 禁止 选择
    jquery的clone方法应用于textarea和select的bug修复不能copy值,clone id重复的解决
    玩javaweb的web.xml编译路径
    程序员笔记之设计(一)
    Eclipse清除SVN密码
    Java 最简单的批处理
  • 原文地址:https://www.cnblogs.com/panchanggui/p/10406680.html
Copyright © 2020-2023  润新知