Get the App
SLTechnology News&Howtos  ›  Development  › 

What's the use of mybatis.type-aliases-package?

Shulou Source: shulou.com Published: 2022-06-03 08:33:23 09月23日 Update

This article mainly introduces the use of mybatis.type-aliases-package, the article is very detailed, has a certain reference value, interested friends must read it!

The crater of mybatis.type-aliases-package

Custom POJO is often used in resultType in mapper.xml, and you can specify references to these POJO with fully qualified names.

For example:

Or you can have mybatis scan to a custom POJO automatically by specifying a POJO scan package in application.properties

As follows:

Mybatis.type-aliases-package=com.majing.learning.mybatis.entity

However, please be careful not to follow the word classpath after mybatis.type-aliases-package=, otherwise mybatis will not find POJO.

The function and usage of mybatis.type-aliases-package

Custom POJO is used in the type or parameterType of resultMap in the mapper.xml file.

For example:

Select * from User select * from User where username=# {username} select password from user where username=# {username} insert into user (username,password) value (# {username}, # {password})

In resultType= "User", User is the custom POJO. You can use the fully qualified name to specify the references to these POJO.

For example:

The second method is to use mybatis.type-aliases-package to specify the POJO scan package to have mybatis scan to the custom POJO automatically.

Configure the following information in the application.propertites configuration file: mybatis.type-aliases-package=com.example.entity

Mybatis.type-aliases-package=com.example.demo.entity above is all the content of this article "what's the use of mybatis.type-aliases-package?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Content that is documents articles configuration middle finger value function information interests words can be passed through guys partners regular meetings methods more knowledge industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Redmi Docker NVidia MariaDB