mybatis报错:The alias 'xxx' is already mapped to the value '*.*.xxx'-阿里云开发者社区

开发者社区> 数据库> 正文
登录阅读全文

mybatis报错:The alias 'xxx' is already mapped to the value '*.*.xxx'

简介: The alias 'xxx' is already mapped to the value '*.*.xxx'

mybatis报错:The alias 'xxx' is already mapped to the value '*.*.xxx'


  先贴上我所遇到的异常,这是我在IDEA上启动iBase4J时遇到的错误:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-11-19 13:43:20.925 [localhost-startStop-1] ERROR [SpringApplication:842] - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'coreTask': Unsatisfied dependency expressed through field 'sessionService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysSessionServiceImpl': Unsatisfied dependency expressed through field 'mapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysSessionMapper' defined in file [D:\Workspace\IDEAProjects\iBase4J\iBase4J-SYS-Service\target\iBase4J-SYS-Service\WEB-INF\classes\org\ibase4j\mapper\SysSessionMapper.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [top/ibase4j/core/config/MyBatisConfig.class]: Invocation of init method failed; nested exception is org.apache.ibatis.type.TypeException: The alias 'MultipleFailureException' is already mapped to the value 'org.junit.runners.model.MultipleFailureException'.
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
	......


   异常重点是:
   org.apache.ibatis.type.TypeException: The alias 'MultipleFailureException' is already mapped to the value 'org.junit.runners.model.MultipleFailureException'.
   经过分析,原来是因为配置文件中,mybatis指定别名时,指定的是一个路径mybatis.typeAliasesPackage=*.**.model*,而不是一个具体类或者固定路径的包,恰巧该项目依赖的jar包中,存在同名类或者包。把*.**.model*修改为org.ibase4j.model*再启动就不报错了。这种问题,可以在配置文件中搜索Aliases,先找到在哪里配置的别名。

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
数据库
使用钉钉扫一扫加入圈子
+ 订阅

分享数据库前沿,解构实战干货,推动数据库技术变革

其他文章