typeAliasesPackageの役割

MyBatisの統合と春

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のマッパーファイル内部の対応するクラス名に直接書き込むことができます

な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>
公開された10元の記事 ウォンの賞賛4 ビュー10000 +

おすすめ

転載: blog.csdn.net/weixin_42528204/article/details/105050097