I T H

IBATIS -> MYBATIS 변환(마이그레이션) 방법 본문

참고용자료

IBATIS -> MYBATIS 변환(마이그레이션) 방법

thdev 2024. 1. 22. 14:04

 ibatis -> mybatis로 변환하는 업무 지시를 받았다.

(단, 보안상 업무의 소스코드는 쓸 수 없으므로, 예시는 개인프로젝트 예시로 대신하겠음.)

ibatismybatis컨버팅툴을 사용하기에 앞서 빌드자동화도구인 ANT를 먼저 설치해야된다.

1. ANT 설치

 

https://ant.apache.org/index.html

 

Apache Ant - Welcome

Welcome Apache Ant™ Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications.

ant.apache.org

1) 설치 사이트에 들어가서 java 버전에 맞게 다운로드 받는다.

 

 

2) 압축을 풀면 이렇게 폴더가 생기는데 시스템 환경변수를 등록해야된다.

 

3) 시스템 환경변수 등록

  1. 환경변수
  2. 새로만들기
  3. ANT_HOME 변수이름 등록
  4. path 설정

환경 변수

변수 이름 등록

path 설정

4) cmd(명령프롬포트창)을 열어서 ANT가 제대로 설치되었는지 확인한다.

ant - version 이라고 치면됨.

 

ANT 설치가 끝났으면 이젠 ibatismybatis컨버팅툴을 설치해야된다. 

 

2. ibatis2mybatis컨버팅툴 설치 및 실행방법

https://github.com/mybatis/ibatis2mybatis

 

GitHub - mybatis/ibatis2mybatis: Tool to convert iBATIS 2 xml files to MyBatis3

Tool to convert iBATIS 2 xml files to MyBatis3. Contribute to mybatis/ibatis2mybatis development by creating an account on GitHub.

github.com

1) 컨버팅 툴을 다운받고 압축을 푼다.

 

 

2) 이젠 ibatis로 된 xml 파일을 컨버팅 툴을 이용해서 mybatis문법으로 바꿔보겠다.

폴더를 클릭하면 destination과 source 폴더가 있는데, source폴더안에 ibatis문법으로 된 xml 파일을 넣으면된다.

 

 

3) cmd 창에서 cd 해당경로를 입력후 ant 라고 입력했을때 정상적으로 실행이 되면 destination 폴더에 mybatis로 바뀐 xml 파일이 생기게 된다.

 

 

이젠 제대로 변환이 되었는지 확인할 수 있는 winMerge 프로그램을 설치해보자!

 

3. WinMerge 설치 및 실행

https://winmerge.org/downloads/?lang=en 

 

Download WinMerge - WinMerge

Download WinMerge The easiest way to install WinMerge is to download and run the Installer. Read the online manual for help using it. WinMerge 2.16.30 The current WinMerge version is 2.16.30 and was released at 2023-04-27. For detailed info on what is new,

winmerge.org

1) 설치를 하면 이런 화면이 뜬다.

 

왼쪽에 ibatis.xml을 넣고, 오른쪽에 mybatis.xml을 넣으면 노란색으로 변환된 부분을 알수있다.

위의 예시를 보면 
1) sqlMap -> mapper
2) #String# -> #{ }
3) resultClass -> resultType
4) parameterClass -> parameterType
으로 정상적으로 ibatis 문법 -> mybatis 문법으로 변환된것을 볼수 있다.