💡 시스템 환경
- OS: Windows 10
- Spring Boot 버전: 3.3.7
- JDK: Amazon Corretto 17
- IDE: Spring Tool Suite (STS) 4
💡 프로젝트 목표
- Spring Boot 프레임워크 활용
- Spring Boot의 기본 동작 원리를 이해하고 활용하여 어플리케이션을 빠르고 효율적으로 구축합니다.
- MVC 패턴 구현
- JSP(JavaServer Pages)를 템플릿 엔진으로 사용하여 MVC(Model-View-Controller) 패턴을 구현합니다.
- 구조적인 코드 작성으로 유지보수성과 확장성을 높입니다.
- 비즈니스 로직 설계
- Spring Boot의 기능을 활용해 프로젝트 내에서 요구사항에 맞는 비즈니스 로직을 설계하고 구현합니다.
- 데이터베이스 접근 기술 활용
- MyBatis를 사용하여 데이터베이스와 상호작용합니다.
- 효율적인 SQL 관리 및 데이터 매핑을 학습합니다.
이 프로젝트는 Spring Boot와 JSP를 사용하여 MVC 패턴을 구현하고, 비즈니스 로직을 생성하는 동시에, MyBatis를 통한 데이터베이스 접근 방법을 탐구하는 것을 목표로 합니다.
💡 프로젝트 설정
1. 프로젝트 생성
Spring Boot 의존성 목록
아래 build.gradle 파일에 의존성을 추가합니다.
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:3.0.3'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.3'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
💡
2. MyBatis 버전 확인
- MyBatis 버전: 3.x.x 이상 필요.
- MyBatis는 SQL 매핑과 데이터 접근을 효율적으로 처리하는 프레임워크입니다.
마이바티스 3 | 소개 – mybatis
마이바티스는 무엇인가? 마이바티스는 개발자가 지정한 SQL, 저장프로시저 그리고 몇가지 고급 매핑을 지원하는 퍼시스턴스 프레임워크이다. 마이바티스는 JDBC로 처리하는 상당부분의 코드와
mybatis.org
호환 버전 확인
Introduction – mybatis-spring-boot-autoconfigure
Using the SpringBootVFS The MyBatis-Spring-Boot-Starter provides the SpringBootVFS as an implementation class of VFS. The VFS is used for searching classes (e.g. target class of type alias, type handler class) from an application (or application server). I
mybatis.org
3. JSP 설정
Spring Boot는 기본적으로 JSP 사용을 권장하지 않지만, 추가 설정을 통해 JSP를 사용할 수 있습니다.
의존성 추가 (build.gradle)
// 의존성 추가
implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
// implementation 'javax.servlet:jstl' spring 3.x.x 버전에서 사용 안됨
implementation group: 'org.glassfish.web', name: 'jakarta.servlet.jsp.jstl', version: '3.0.0'
※ JSP 설정 주의 사항
- Spring Boot 3.x.x 버전에서는 javax.servlet 대신 jakarta.servlet 패키지를 사용해야 합니다.
- JSP는 Spring Boot의 권장 템플릿 엔진이 아니며, Thymeleaf 또는 FreeMarker 사용을 권장합니다.
💡 Bank App 개발 방향
- Spring Boot 프로젝트 구성
- Gradle을 사용해 프로젝트를 생성하고 필요한 의존성을 추가합니다.
- MVC 구조 구현
- Controller, Service, Repository 계층을 분리해 유지보수성을 높입니다.
- JSP를 사용해 View를 생성합니다.
- MyBatis를 활용한 데이터베이스 접근
- SQL 매핑을 통해 효율적인 데이터베이스 연동을 구현합니다.
- H2와 MySQL 데이터베이스 연동
- 개발 환경에서는 H2를, 운영 환경에서는 MySQL을 사용합니다.
이 가이드를 따라 설정 및 개발을 진행하면, Bank App 프로젝트의 초기 구성을 완성할 수 있습니다. MyBatis 활용과 MVC 패턴 구현을 통해 학습 목표를 달성해 보세요!
다음 포스팅에서 이어서 !!
'Spring' 카테고리의 다른 글
[Spring boot] Bank App - 모델링 (0) | 2025.01.14 |
---|---|
[Spring boot] Bank App - 코딩 컨벤션 (0) | 2025.01.14 |
[Spring boot] Bank App - 패키지 설정 (0) | 2025.01.14 |
[Spring boot] Bank App - 디자인 시안 확인 (0) | 2025.01.14 |
[Spring boot] Bank App - yml 파일 설정 (1) | 2025.01.14 |