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】,

 

posted @ 2017-08-17 12:13  剑握在手  阅读(439)  评论(0编辑  收藏  举报
返回顶部↑