微服务中数据源、以及部分对象在父工程中已存在,导致打包报错的异常分析

##问题描述
###异常1

[org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext:559] -- Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: 
 Error creating bean with name 'shiroFilter' defined in class path resource [com/dhcc/upsr/manage/sys/auth/shiro/config/ShiroConfig.class]:
  Bean instantiation via factory method failed;
   nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.shiro.spring.web.ShiroFilterFactoryBean]: Factory method 'shiroFilter' threw exception; 
   nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in class path resource [com/dhcc/upsr/manage/sys/auth/shiro/config/ShiroConfig.class]: 
   Bean instantiation via factory method failed; 
   nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.shiro.mgt.SecurityManager]: 
   Factory method 'securityManager' threw exception; 
   nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
   Error creating bean with name 'primaryRealm': Unsatisfied dependency expressed through field 'sysUserInfoService'; 
   nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
   Error creating bean with name 'sysUserInfoService': 
   Unsatisfied dependency expressed through field 'sysUserInfoDao'; 
   nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
   Error creating bean with name 'sysUserInfoDao' defined in URL [jar:file:/home/upsr/instance/ms-batch-1.0.0-SNAPSHOT.jar!/BOOT-INF/lib/ms-auth-0.1.0-SNAPSHOT.jar!/com/dhcc/upsr/manage/sys/user/dao/SysUserInfoDao.class]: 
   Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [tk/mybatis/mapper/autoconfigure/MapperAutoConfiguration.class]: 
   Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: 
   Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; 
   nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'class path resource [auth/db-mapper/oracle/sys/SysDataSourseDetailMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'class path resource [auth/db-mapper/oracle/sys/SysDataSourseDetailMapper.xml]'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.dhcc.upsr.manage.sys.datasource.dao.SysDataSourceDetailDao.BaseResultMap

先对异常信息进行一个层次分离;对于异常,我们首先要去查看Caused 或者Caused by 后面的内容,一般就是真正报错的原因
所以上面抽取出来就是:

Cause: java.lang.IllegalArgumentException: 
Result Maps collection already contains value for 
com.dhcc.upsr.manage.sys.datasource.dao.SysDataSourceDetailDao.BaseResultMap

####首先类型:
java.lang.IllegalArgumentException–非法数据异常

####具体信息:
Result Maps collection already contains value for
就是映射集合里面已经包含SysDataSourceDetail对象的映射

####解决:
就根据对象信息:com.dhcc.upsr.manage.sys.datasource.dao.SysDataSourceDetailDao.BaseResultMap
全局搜索看是否其他地方有相同的SysDataSourceDetail信息即解决

###异常2

Caused by: 
org.springframework.context.annotation.ConflictingBeanDefinitionException: 
Annotation-specified bean name 'upsrDictDtlService' for bean class 
[com.dhcc.upsr.manage.parm.dict.service.impl.UpsrDictDtlServiceImpl] 
conflicts with existing, non-compatible bean definition of same name and class
[com.dhcc.upsr.manage.cache.service.impl.UpsrDictDtlServiceImpl]

####首先类型:
org.springframework.context.annotation.ConflictingBeanDefinitionException
这是Bean定义冲突,就是有两个相同名字的类

####具体信息:
Annotation-specified bean name ‘upsrDictDtlService’ for bean class
这里可以知道重复的Bean的名字为upsrDictDtlService

后面跟的是两个Bean的包路径,直接去找即可

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值