欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Springboot2.0整合tk.mybatis出问题

程序员文章站 2022-07-15 10:10:56
...

Springboot2.0整合tk.mybatis出问题

SpringBoot与tk.mybatis整合遇到的问题

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'componentController': Unsatisfied dependency expressed through field 'XXXXService'; 
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'componentServiceImpl': Unsatisfied dependency expressed through field 'componentMapper'; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ds1ComponentMapper' defined in file [XXXXXXX]: Cannot resolve reference to bean 'ds1SqlSessionTemplate' while setting bean property 'sqlSessionTemplate'; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ds1SqlSessionFactory': Invocation of init method failed;
nested exception is java.lang.StringIndexOutOfBoundsException: String index out of range: -41

Springboot1.X升级成2.X整合通用mapper时候,出现无法创建通用mapper生成的mapper文件的bean。

<dependency>
      <groupId>tk.mybatis</groupId>
      <artifactId>mapper-spring-boot-starter</artifactId>
  </dependency>

这个里面增添

<dependency>
      <groupId>tk.mybatis</groupId>
      <artifactId>mapper-spring-boot-starter</artifactId>
  </dependency>
  <dependency>
<exclusions>   
 <exclusion>        
 	<artifactId>mybatis</artifactId>        
	<groupId>org.mybatis</groupId>   
 </exclusion>    
 <exclusion>       
  <artifactId>mybatis-spring</artifactId>        
  <groupId>org.mybatis</groupId>    
 </exclusion></exclusions>

就完美解决了