Spring Boot application integrates mybatis quickly, to support different statements of different databases.
- Import dependencies
<dependency>
<groupId>cn.unikue.springstarter</groupId>
<artifactId>mybatis-provider-spring-boot-starter</artifactId>
<version>LATEST</version>
</dependency>By default, this starter will auto take effect, you can turn it off by
spring.mybatis-provider.enabled = false
- Configure Spring Boot
application.ymlwith prefixspring.mybatis-provider(Optional)
spring:
mybatis-provider:
configFile: 'classpath:/META-INF/mybatis/database-id-provider.xml'This will create a DatabaseIdProvider bean, which supports most popular relational databases in the world.
- Write your mybatis mapper statements as following:
<select id="foo" resultType="bar" databaseId="mysql">
</select>Note that the
databaseIdsegment, that is the database identifier from yourconfigFilenode of the previous step.
- Github: https://github.com/unikueltd/mybatis-provider-spring-boot-starter
- Mybatis homepage: https://mybatis.org/mybatis-3
- Mybatis github: https://github.com/mybatis/mybatis-3
- Relational databases: https://db-engines.com/en/ranking/relational+dbms
- jdk 17+
This project is under the Apache License 2.0
See the NOTICE.txt file for required notices and attributions.
You like this package? Then donate to us to support the development.
Beijing Unikue Network Technology Ltd.
- Unikue: https://unikue.cn