项目场景:
在mapper.xml文件里,我们可能需要用到别名,需要在yml进行配置:
![在这里插入图片描述](https://img-blog.csdnimg.cn/a9c50fafe05e4015baf6eaea33c33aa6.png)
mybatis:
mapperLocations: classpath:mapper/*.xml
type-aliases-package: com.example.springcloud.entity # 所有Entity别名类所在包
问题描述
yml文件配置后,但在mapper.xml中通过parameterType使用却并未生效。
![在这里插入图片描述](https://img-blog.csdnimg.cn/05e3658e1abb40d5930d5a1dee5a43c3.png)
解决方案:
在resource目录下,新建config.xml,并配置别名
![在这里插入图片描述](https://img-blog.csdnimg.cn/4522f04836d84d2691562e4ea76153de.png)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<!-- 指定一个包名,MyBatis会在包名下搜索需要的JavaBean-->
<package name="com.example.springcloud.entity"/>
</typeAliases>
</configuration>
问题成功解决:
![在这里插入图片描述](https://img-blog.csdnimg.cn/1f90261120aa4f6aa73562db236b776c.png)