SoFunction
Updated on 2025-04-05

Interpretation of the usage of type-aliases-package

Type-aliases-package function

In Mybatis file, the resultType type or paramterType will return a custom entity. At this time, these entities can be specified with the full class name.

For example:

    <select  resultType="">
        SELECT
        <include ref/>
        FROM USER_INFO WHERE 1=1
    </select>

The resultType in it returns the full class name.

Actually, it can be usedtype-aliases-packageSpecify the entity scan package class in the entity to let mybatis scan to a custom entity.

type-aliases-package configuration

  1. In springboottype-aliases-packageConfiguration
-aliases-package=
  1. SpringMVCtypeAliasesPackageConfiguration
    &lt;bean  class=""&gt;
        &lt;!-- Data Source --&gt;
        &lt;property name="dataSource" ref="datasource"&gt;&lt;/property&gt;
        &lt;!-- Alias --&gt;
        &lt;property name="typeAliasesPackage" value=""&gt;&lt;/property&gt;
        &lt;!-- sqlMap file path --&gt;
        &lt;property name="mapperLocations" value="classpath*:mapper/*"&gt;&lt;/property&gt;
    &lt;/bean&gt;

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.