반응형
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
반응형
'개발 > Web' 카테고리의 다른 글
하나의 tomcat에 같은 프로젝트 두개 이상 띄우기 : 'webapp.root' 에러 (0) | 2021.12.13 |
---|---|
[Spring Boot] spring security - CSRF 적용 , +) ajax csrf 적용 (0) | 2021.12.07 |
[JSP/HTML] ERR_CACHE_MISS 에러 발생 (0) | 2021.12.01 |
[Apache] web-was 연동, socket_timeout 설정 이슈 (0) | 2021.11.30 |
[Tomcat] JNDI 정보 암호화(DB정보 : url, username, passowrd) / KDF 알고리즘 이용 (0) | 2021.11.30 |
댓글