解决The import org.mybatis cannot be resolved问题。

本文解决了一个在SpringBoot项目中集成JTA时遇到的问题:Theimportorg.mybatiscannotberesolved。作者分析了问题原因,发现pom文件中已包含mybatis相关jar包,但缺少mybatis-spring依赖。最终通过引入正确版本的mybatis-spring(1.3.1)解决了编译错误。

问题

最近在研究SpringBoot集成JTA,参照网上一个例子并在工程中实践时,编译报错:

The import org.mybatis cannot be resolved

分析

经过分析发现,pom中已经定义了mybatis相关jar包。

但在mybatis的源码中发现,并不存在“org.mybatis.spring.*”这样的package。

于是,去Maven大本营找类似jar包,很快就发现了MyBatis Spring这个可疑的包。经过验证,确定无误。

 

解决

由于使用的是MyBatis3.4.5,对应的MyBatis Spring版本1.3.1.(最新版1.3.2要求MyBatis 3.4.6)

在pom文件中加入对应依赖即可。

<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>1.3.1</version>
</dependency>

 

文章结束。

Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jfSiteDeviceBindController' defined in file [D:\workspace\lottery-ticket-new\ruoyi-admin\target\classes\org\dromara\screen\controller\JfSiteDeviceBindController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'jfSiteDeviceBindServiceImpl' defined in file [D:\workspace\lottery-ticket-new\ruoyi-admin\target\classes\org\dromara\screen\service\impl\JfSiteDeviceBindServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'jfSiteDeviceBindMapper' defined in file [D:\workspace\lottery-ticket-new\ruoyi-admin\target\classes\org\dromara\screen\mapper\JfSiteDeviceBindMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory': Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception with message: Unresolved compilation problems: The import org.dromara.common.core cannot be resolved The import org.dromara.common.mybatis cannot be resolved The import org.dromara.common.mybatis cannot be resolved The import org.dromara.common.mybatis cannot be resolved The import org.dromara.common.mybatis cannot be resolved BaseMapperPlus cannot be resolved to a type DataPermission cannot be resolved to a type DataColumn cannot be resolved to a type The method selectVoList(Wrapper<SysDept>) is undefined for the type SysDeptMapper DataPermission cannot be resolved to a type DataColumn cannot be resolved to a type The method selectVoPage(Page<SysDept>, Wrapper<SysDept>) is undefined for the type SysDeptMapper DataPermission cannot be resolved to a type DataColumn cannot be resolved to a type The method selectCount(LambdaQueryWrapper<SysDept>) is undefined for the type SysDeptMapper DataBaseHelper cannot be resolved StreamUtils cannot be resolved The method selectObjs(LambdaQueryWrapper<SysDept>) is undefined for the type SysDeptMapper at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:804) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:240) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1395) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1232) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)v没有放到default下启动报错信息
最新发布
12-05
评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值