2    常见错误
2.1  mybatis 配合springboot启动,报错Field XXX required a bean of type XXX that could not be found

https://blog.csdn.net/Julycaka/article/details/80622754?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control

 

 

2.2  mybatis 配合springboot启动,启动报错 Error creating bean with name 'XXX'

问题已经解决,自己在generatorConfig.xml 中配置了两个不同的table,一个不用的table  生成了pojo,mapper以及*mapper.xml,但是项目中没有引用无用的table,所以报错,在  generatorConfig.xml 除去那个无用的table即可。

除去:

<table tableName="aaa"></table>

2.3  mybatis 配合springboot,Error invoking SqlProvider method (tk.mybatis.mapper.provider.base.BaseInsertProvider.dynamicSQL)

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error invoking SqlProvider method (tk.mybatis.mapper.provider.base.BaseInsertProvider.dynamicSQL).  Cause: java.lang.InstantiationException: tk.mybatis.mapper.provider.base.BaseInsertProvider
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
    at com.sun.proxy.$Proxy65.insert(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
 
    ... 94 more
2020-12-20 17:36:40.950  WARN 12256 --- [nio-8088-exec-4] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error invoking SqlProvider method (tk.mybatis.mapper.provider.base.BaseInsertProvider.dynamicSQL).  Cause: java.lang.InstantiationException: tk.mybatis.mapper.provider.base.BaseInsertProvider]

 

解决方法:

在SpringBoot的启动类上,使用@MapperScan注解时引入了错误的包下的。

  正确的应该是:import tk.mybatis.spring.annotation.MapperScan;

  错误的引入了:import org.mybatis.spring.annotation.MapperScan;

 

 

2.4  mybatis 配合springboot,启动报错  Error creating bean with name
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-12-22 07:19:49.255 ERROR 6172 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myBatisCRUDController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysUserMapper' defined in file [F:\xiangmu3\Xin\FuQiang\Springboot_1\download_resource\SpringbootDemo\demo\demo\target\classes\com\example\demo\mapper\SysUserMapper.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: 'file [F:\xiangmu3\Xin\FuQiang\Springboot_1\download_resource\SpringbootDemo\demo\demo\target\classes\mapper\SysUserMapperCus.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'com.imooc.pojo.SysUser'.  Cause: java.lang.ClassNotFoundException: Cannot find class: com.imooc.pojo.SysUser

 

解决方法:核查相关mapper.xml

posted on 2020-12-20 16:31  菜鸟乙  阅读(212)  评论(0编辑  收藏  举报