项目场景:
在mapper.xml文件里,我们可能需要用到别名,需要在yml进行配置:
mybatis:
mapperLocations: classpath:mapper/*.xml
type-aliases-package: com.example.springcloud.entity # 所有Entity别名类所在包
问题描述
yml文件配置后,但在mapper.xml中通过parameterType使用却并未生效。
解决方案:
在resource目录下,新建config.xml,并配置别名
<?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>
问题成功解决: