tomcat启动spring项目,报具有该名称的xxxbean已经在xxx定义,覆盖被禁止
The bean ‘xxxRepository’, defined in xxx defined in @EnableJpaRepositories declared on PropertyConfig, could not be registered. A bean with that name has already been defined in cn.xfdc.shopproject.repository.property.xxxy defined in @EnableJpaRepositories declared on DataSourceConfig and overriding is disabled.
查到问题 说 'xxx’扫描重复
刚开始分析时以为SpringBoot本身具有自动配置,现在自动配置时发生冲突了,那么我们可以将冲突的部分排除掉,即告诉SpringBoot,某个类不用帮我自动配置了,这里我们将Druid的关于数据源的配置排除掉。
因为hcHousingResourcesBaseRepository(JPA接口) 这个bean的名字在容器中已经有了 所以我的想法是先排除
第一种排除方法
在配置类中排除自动配置的 并在配置文件中配置 自动配置类bean名字可以覆盖
@SpringBootApplication(exclude={HcHousingResourcesRepository.class})
spring:datasource:main:allow-bean-definition-overriding: true
第二种方法是排除自定义的
@ComponentScan(excludeFilters= {@ComponentScan.Filter(type= FilterType.ANNOTATION, value= {HcHousingResourcesRepository.class})})
但是都没有用 放到tomcat下还是会报错
最终解决方案:
@Component(value = “HcHousingRepository”)
spring:datasource:main:allow-bean-definition-overriding: true
自定义一下接口的名字 然后将之前的bean名称覆盖 启动的时候就不会冲突 从而解决bean启动因为名称冲突的问题
tomcat启动spring项目,报具有该名称的xxxbean已经在xxx定义,覆盖被禁止相关推荐
- 启动Spring项目报错,Springboot启动报错 Disconnected from the target VM 解决过程
启动Spring项目报错,Springboot启动报错 Disconnected from the target VM 解决过程 大概率是缺少了一下依赖 <dependency><g ...
- tomcat启动maven项目报错,严重: Error configuring application listener of class org.springframework.web.contex
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderLis ...
- Tomcat启动时项目重复加载,导致资源初始化两次的问题
最近在项目开发测试的时候,发现Tomcat启动时项目重复加载,导致资源初始化两次的问题 导致该问题的原因: 如下图:在Eclipse中将Server Locations设置为"Use Tom ...
- IDEA整合Tomcat启动javaweb项目
1.前言 突然兴起想要写这么一篇博客,不是因为别的,纯属是因为小编还是一个小白的时候,听某马和某硅谷的javaweb网课时,遇到这个章节一直启动不起来,虽然小编依旧是个菜鸡,但是今时不同往日了,小编已 ...
- Tomcat启动Maven项目异常:java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
Tomcat启动Maven项目异常:java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext 参考文 ...
- Tomcat 运行 maven项目报错 com.sun.faces.config.ConfigureListener
Tomcat 运行 maven项目报错,异常如下 java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleExcep ...
- 启动项目报错:null, message from server: “Host ‘XXX‘ is not allow
step1:之前一直都是连的测试环境由docker镜像生成的mysql,公司老是断电导致mysql数据崩坏,于是在本地整了个8.0.18版本的mysql,启动项目报错:null, message fr ...
- 启动vue项目报错:npm ERR! enoent ENOENT: no such file or directory, open‘E:xxxx\package.json‘
问题描述:cmd / VSCode 启动vue项目报错:npm ERR! enoent ENOENT: no such file or directory, open'E:xxxx\package.j ...
- SpringBoot项目用tomcat启动,没有报错,控制台只输出org.apache.catalina.startup.catalina.start server startup in xxxms
背景:最近在使用SpringBoot项目过程中,代码写好测试完,部署到服务器上启动使用外置的tomcat启动,控制台只输出org.apache.catalina.startup.catalina.st ...
最新文章
- Aliyun 挂载硬盘
- ASP.NET MVC实现一个用户只能登录一次 单用户登录
- 今日arXiv精选 | 13篇EMNLP 2021最新论文
- 随笔--互联网进化论
- 【设计模式】—— 访问者模式Visitor
- as_hash ruby_Hash.merge(other_hash)方法与Ruby中的示例
- 指针作为函数参数 进行内存释放 并置NULL
- mysql 动态加载数据库数据库连接,如何根据每个客户端动态连接mysql数据库?
- jquery access方法 有什么用
- lucene使用与优化
- 马化腾:互联网企业竞争要注重什么
- SQL--“索引超出了数组界限”
- 基于PHP+MySQL的大学生健康管理系统
- AWG#线规及其载流能力和电阻值
- 【最全】PS各个版本下载安装及小试牛刀教程(PhotoShop CS3 ~~ PhotoShop 2022)
- DCDC基础(2)--BUCK芯片的各个引脚是什么意思?带你深入了解BUCK电源的稳压原理
- 【MAF】MAF插件框架简介
- incsgo 可直接立刻取回皮肤的CSGO饰品皮肤开箱网站
- 机器学习 28 个视频教程
- 渗透测试成功的8个关键