๋ฐ์ํ
1.gradle ํน์ maven์ 'mybatis-spring-boot-starter' ์ถ๊ฐ
compile("org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4")
<!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>
2. application.yml์ mybatis ์ค์ ํ์ผ(mybatis-config.xml) ๋ฐ xml ํ์ผ ์ธํ
mybatis:
config-location: classpath:mybatis-config.xml
mapper-locations: classpath:mapper/postgresql/*.xml
3. mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD SQL Map Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<!-- http://www.mybatis.org/mybatis-3/configuration.html#settings ์ฐธ๊ณ -->
<settings>
<!-- query ๊ฒฐ๊ณผ ์ปฌ๋ผ์ ๊ฐ์ด null์ผ ๊ฒฝ์ฐ result์ null๋ก settingํ ์ง ์ฌ๋ฌด -->
<setting name="callSettersOnNulls" value="true" />
<!-- null parameter ํ์ฉ -->
<setting name="jdbcTypeForNull" value="NULL" />
</settings>
<!-- vo type aliases -->
<typeAliases>
<typeAlias type="com.xxx.xxx.xxx.xxx.vo.job.BatchJobVo" alias="batchJobVo"/>
</typeAliases>
</configuration>
4. postgresql/*.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxx.xxx.xxx.xxx.dao.BatchDao">
<!-- batch ๋์ select -->
<select id="selectBatchList" resultType="batchJobVo">
SELECT REQ_ID
FROM BATCH
WHERE 1=1
AND STATUS = '2'
</select>
</mapper>
5. BatchDao.java
@Mapper
public interface BatchDao {
List<BatchJobVo> selectBatchList();
}
728x90
๋ฐ์ํ
๋๊ธ