Spring Boot application integrates mybatis
quickly, to support different statements of different databases.
- Import dependencies
<dependency>
<groupId>com.yookue.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.yml
with 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
databaseId
segment, that is the database identifier from yourconfigFile
node of the previous step.
- Github: https://github.com/yookue/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 Yookue to support the development.
- Yookue: https://yookue.com