springboot 解决 The bean 'userRepository', defined in null, could not be registered. A bean with that ...

 

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:\MyWork\workspace_idea\springbootssm\target\classes started by panchanggui in C:\MyWork\workspace_idea\springbootssm)
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:\MyWork\workspace_idea\springbootssm\target\classes\com\fantasy\springbootssm\mapper\UserRepository.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:\MyWork\workspace_idea\springbootssm\target\classes\com\fantasy\springbootssm\mapper\UserRepository.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

 

 
 

 

转载于:https://www.cnblogs.com/panchanggui/p/10406680.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值