Mybatis profile configuration

<Mappers> used when mybatis initialization, told mybatis Mapper mapping file which need to be introduced.

There are two sub-elements 1. <package> 2. <mapper> in <mappers> in

1. The first embodiment of the configuration file mapping

<Package name = "map file where the package name">

Note: This must be guaranteed way interface name (e.g. IUserDao) and name xml (IUserDao.xml) the same, must also be in the same package.

2. The second mode: <mapper resource = "">

In this way it does not guarantee the same interfaces in the same package with the same name. For example: <mapper resource = "com / yidu / dao / WsUserMapper.xml" />

Enter the path to

3. The third way: <mapper url = "file path name">

This way I know is to use this: the absolute path

<mapper url="file:///D:/JAVA/MavenProject/day02_mybatisCRUD/src/main/resources/com/yidu/dao/UsersMapper.xml"/>

4. The fourth embodiment: <mapper class = "Path Interface">

In this manner the first embodiment and the same requirements, to ensure the interface name (e.g. IUserDao) and name xml (IUserDao.xml) the same, must also be in the same package. For example: <mapper class = "com.yidu.dao.WsUserMapper" />

 

 

Released seven original articles · won praise 0 · Views 118

Guess you like

Origin blog.csdn.net/winwinwin99/article/details/105331244
Recommended