Spring Boot项目升级:Mybatis升级碰到的问题对应

这篇文章记录一下Spring Boot从1.5.22升级至2.3.3后,升级Mybatis所碰到的问题。

目录

  • 版本说明
  • 问题现象
  • 修改参考
  • 修改方式


版本说明

  • Spring Boot版本:2.3.3

  • Mybatis升级前

    
        org.mybatis.spring.boot
        mybatis-spring-boot-starter
        1.3.5
    
  • Mybatis升级后
    
        org.mybatis.spring.boot
        mybatis-spring-boot-starter
        2.1.3
    

问题现象

[main] ERROR org.springframework.boot.web.embedded.tomcat.TomcatStarter - Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'SSOFilterConfig': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SSOFilter': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SSOService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoSupport': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionTemplate' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'createSqlSessionFactoryBean' defined in class path resource [AAAA.class]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'URL [jar:file:/Users/liumiao/Desktop/BBB.jar!/BOOT-INF/lib/cd-2.1.7.jar!/CCC.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'URL [jar:file:/Users/liumiao/Desktop/BBB.jar!/BOOT-INF/lib/DDD.jar!/CCC.xml]'. Cause: org.apache.ibatis.builder.BuilderException: Ambiguous collection type for property 'children'. You must specify 'javaType' or 'resultMap'.
...
org.apache.ibatis.builder.BuilderException: Ambiguous collection type for property 'children'. You must specify 'javaType' or 'resultMap'
...
WARN  org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
...

修改示例


修改参考

参考了如下Mybatis官方内容,所提示的方法中没有解决本文的问题,但是给出了提示。

  • https://github.com/mybatis/mybatis-3/issues/364

修改方式

最终使用如下方式修改解决了升级时在运行阶段碰到的问题。

  • 修改前
		
			
			
		
  • 修改后
		
			
			
		

你可能感兴趣的:(#,spring快速入门,#,持久层框架快速入门,SpringBoot2,Mybatis2.1.3,升级)