`

Spring整合Mybatis的Model别名设置

阅读更多

1.在mybatis_config.xml中Mybatis别名设置

<?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>
         <typeAlias alias="User" type="com.xxx.User"/>
    </typeAliases>
 
    <!-- 映射map -->
    <mappers>
    </mappers>
</configuration>

 2.还可以在spring.xml中配置:

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
		p:dataSource-ref="dataSource" 
		p:configLocation="classpath:mybatis-config.xml"
		p:mapperLocations="classpath:mapper/*.xml" 
		p:typeAliasesPackage="com.xxx.pojo"
		/>

 

2
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics