Mybatis 通过扫描 自动生成别名

Posted 剑握在手

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mybatis 通过扫描 自动生成别名相关的知识,希望对你有一定的参考价值。

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>

<property name="typeAliasesPackage" value="com.xxx"/> <property name="typeAliasesSuperType" value="com.xxx.xxx.Xxx"/>

<property name="mapperLocations" value="classpath:/mappings/**/*.xml"/> <property name="configLocation" value="classpath:/mybatis-config.xml"></property> </bean>

加粗放大的这两行即是。

要为【com.xxx】下目标类生成别名的话,那么这些类必须继承同一个父类【com.xxx.xxx.Xxx】,

 

以上是关于Mybatis 通过扫描 自动生成别名的主要内容,如果未能解决你的问题,请参考以下文章

关于Mybatis-别名

typeAliases别名

mybaits3.2.8 别名包扫描通配符

mybatis第二天

Spring整合MyBatis (使用扫描包配置mapper代理)

mybatis读取不到第三方jar中类的别名