mybatis和spring整合
typeAliasesPackage自动配置别名
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 自动配置别名 -->
<property name="typeAliasesPackage" value="com.m" />
<!-- <property name="typeAliasesSuperType" value="com.m.entity.Book"/> -->
<!-- mybatis mapper配置文件 -->
<property name="mapperLocations" value="classpath:com/m/mappers/*.xml" />
</bean>
当你设置这个 ,那么在Mybatis的Mapper文件里面就可以直接写对应的类名 而不用写全路径名了
例
设置前:parameterMap=“com.m.City”
设置后:
设置后:
<update id="updateCity" parameterMap="City">
update
city
set
<if test="provinceId!=null">
province_id = #{provinceId},
</if>
<if test="cityName!=null">
city_name = #{cityName},
</if>
<if test="description!=null">
description = #{description}
</if>
where
id = #{id}
</update>