工程中引入其他工程的包,由于两个工程中有重名的两个bean,导致在启动时提示如下错误:

根据bean名称在ide中查找,找到这两个重名的类,可以看到由于这两个类使用@Service标注,此时如果不使用命名,那么Spring会在扫描时,将类名首字母小写作为key,放到一个全局Map中维护。此时,会出现两个键相同的Service,由于Spring不使用覆盖的方式处理具有相同键的不同全类名,所以扫描时提示冲突。

解决方法:保持容器中bean的名称不重复,对其中的一个bean进行自定义命名。

bean名称相同冲突Annotation-specified bean name 'xx' for bean class [xxx] conflicts with existing, non-compatible bean definition of same name and class[xxx]的更多相关文章

  1. 获取并打印Spring容器中所有的Bean名称

    思路: 1.实现Spring的ApplicationContextAware接口,重写setApplicationContext方法,将得到的ApplicationContext对象保存到一个静态变量 ...

  2. Spring中用@Component、@Repository、@Service和 @Controller等标注的默认Bean名称会是小写开头的非限定类名

    今天用调度平台去调用bean中的方法时,提示找不到bean.经查,发现是由于如果在标注上没有提供name属性值,则默认的bean名称是小写开头的,而不是大写开头的. 下面是其他文档参阅: 使用过滤器自 ...

  3. 【Spring】10、Spring中用@Component、@Repository、@Service和 @Controller等标注的默认Bean名称会是小写开头的非限定类名

    @Service用于标注业务层组件(我们通常定义的service层就用这个) @Controller用于标注控制层组件(如struts中的action) @Repository用于标注数据访问组件,即 ...

  4. Spring中默认bean名称的生成策略/方式修改

    最近公司项目打算模块化,其实一个原因也是为了能够整合公司多个业务的代码,比如一个资源xxx,两个业务中都有对这个资源的管理,虽然是一个资源,但是是完全不同的定义.完全不同的表.不同的处理逻辑.所以打算 ...

  5. 创建在类路径资源[applicationcontext]中定义名为“工厂”的bean时出错。:在设置bean属性“dataSource”时,无法解析对bean“dataSource”的引用;嵌套异常是org.springframe .beans.factory。BeanCreationException:创建名为“数据源”的bean时出错,该名称是在类路径资源[applicationcontext

    控制台报错: 创建在类路径资源[applicationcontext]中定义名为“工厂”的bean时出错.:在设置bean属性“dataSource”时,无法解析对bean“dataSource”的引 ...

  6. Spring MVC-处理程序映射(Handler Mapping)-Bean名称Url处理程序映射(Bean Name Url Handler Mapping)示例(转载实践)

    以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_beannameurlhandlermapping.htm 说明:示例基于Spri ...

  7. SpringMVC conflicts with existing, non-compatible bean definition of same name and class 的解决办法

    问题起因 最近,项目组的里的同事遇到一个问题,他自己负责的模块,SpringMVC的Controller与其他模块的Controller 类名重名了,导致整个工程都起不来了. 后台报的错误是这样的: ...

  8. Annotation-specified bean name 'userDaoImpl' for bean class [***] conflicts with existing, non-compatible bean definition of same name and class [***]

    使用Spring开发的时候报错如下: Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionExcept ...

  9. spring 'arroudAspect' for bean class [com.dw.test.ArroudAspect] conflicts with existing, non-compatible bean definition of same name and class [com.dw.aspect.ArroudAspect]

    Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: ...

随机推荐

  1. jhipster技术栈研究

    背景: 公司新的微服务项目都用jhipster脚手架来开发,这篇博客是jhipster里面涉及到技术的汇总目录 一.官方文档中涉及到的技术栈 前端技术栈 Angular / React / Vue R ...

  2. VS调试 DataTable (转载)

    调试的时候遇到一个问题:不知道怎么在自动窗口或者添加监视那里查看DataSet或者DataTable的具体的值.度娘了一下很多都是添加DataTable.Rows[][]监视,但是一行一列地看还是有点 ...

  3. 经典sql server基础语句不全

    1.几个简单的基本的sql语句 选择: select * from table1 where 范围 插入: insert into table1(field1,field2) values(value ...

  4. CentOS7安装MySQL5.7及Tomcat8.5

    在CentOS7服务器上部署FR项目应用 一.安装CentOS-7_x86_64 1.CentOS7:带GUI的服务器(FTP服务器.JAVA平台.兼容性程序库.开发工具.安全性工具.系统管理工具): ...

  5. ​Python 3 新特性:类型注解——类似注释吧,反正解释器又不做校验

    ​Python 3 新特性:类型注解 Crossin ​ 上海交通大学 计算机应用技术硕士 95 人赞同了该文章 前几天有同学问到,这个写法是什么意思: def add(x:int, y:int) - ...

  6. python笔记42-http请求命令行工具(httpie)

    前言 通常我们需要快速的测试某个接口通不通,一般linux上用curl去发http请求,但是这个命令行工具语法有点复杂了,不够直观. python有一个给人类使用的requests库,非常的简单方便. ...

  7. python Thread 函数

    构造方法: Thread(group=None, target=None, name=None, args=(), kwargs={})  group: 线程组,目前还没有实现,库引用中提示必须是No ...

  8. 题解 LA2889

    题目大意 多组数据,每组数据给出一个正整数 \(n\),输出第 \(n\) 大的回文数(即 \(1,2,3,\cdots\)). 分析 不难发现,\(n\) 位的回文数有 \(9*10^{\lfloo ...

  9. [NPM + React] Prepare a Custom React Hook to be Published as an npm Package

    Before we publish our package, we want to make sure everything is set up correctly. We’ll cover vers ...

  10. 洛谷 UVA12101 Prime Path 题解

    一道经典的BFS 用四个for搜索四位就行了,只要能推出怎么只变4位中的一位就很水了 #include<iostream> #include<cstring> #include ...