application.properties 의 설정과 Mapper 인터페이스 생성, Mapper XML 파일 생성만으로 별다른 설정 없이 간단히 사용 가능
pom.xml
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc10</artifactId>
<version>19.18.0.0</version>
</dependency>
application.properties
# mybatis
mybatis.type-aliases-package=kr.jobtc.mybatis
mybatis.mapper-locations=static/mapper/*.xml
# oracle
spring.datasource.data-source-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.url=jdbc:oracle:thin:@127.0.0.1:1521:ORACLEDB
spring.datasource.username=
spring.datasource.password=
TestMapper.java
@Mapper
public interface TestMapper {
public String selectTest();
}
Test.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="kr.co.dagroup.dao.gw.KyoceraMapper">
<select id="selectTest" parameterType="map" resultType="map">
SELECT SYSDATE FROM DUAL
</select>
</mapper>