MyBatis 라이브러리 설치

https://mvnrepository.com/artifact/org.mybatis/mybatis

메뉴얼

https://mybatis.org/mybatis-3/ko/getting-started.html

MyBatis 세팅 및 사용법

database.properties


jdbc.driver=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@localhost:1521:xe
jdbc.username=hr
jdbc.password=hr

mybatis-config.xml


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "<http://mybatis.org/dtd/mybatis-3-config.dtd>">
<configuration>
  
  <!-- 추가 -->
  <properties resource="co/dev/mybatisdb/database.properties"></properties>
  
  <environments default="development">
    <environment id="development">
      <transactionManager type="JDBC"/>
      <dataSource type="POOLED">
        <!-- database.properties 사용 -->
        <property name="driver" value="${jdbc.driver}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
      </dataSource>
    </environment>
  </environments>
  <mappers>
  	<!-- mapper 파일과 연결 -->
    <mapper resource="co/dev/mybatisdb/memberMapper.xml"/>
  </mappers>
</configuration>

memberMapper.xml