您现在的位置是:首页 > 文章详情

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

日期:2018-11-18点击:399

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,先找到在哪里配置的别名。

原文链接:https://yq.aliyun.com/articles/670929
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章