- July 24, 2023
- Posted by: Rahul Thachilath
- Category: Programming
No Comments
MyBatis is one of the most commonly used open-source frameworks for implementing SQL database access in Java applications. In this tutorial, we will integrate mybatis with spring and spring-boot.
To start with there are two main following dependencies
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.2</version>
</dependency>
In our example, we will be using oracle as the database.
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
</dependency>
YML bases configurations
spring:
datasource:
url: 'jdbc:oracle:thin:@SERVER_URL'
username: 'USERNAME'
password: 'PASSWORD'
driverClassNames: oracle.jdbc.OracleDriver
mybatis:
typeAliasesPackage: org.unctad.dmfas.debtServices.repository.mappers
configuration:
map-underscore-to-camel-case: true
jdbcTypeForNull: VARCHAR
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl