2024/08 99

[설치 메뉴얼] MyBatis 설치하기

1. 의존성 설정 확인https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter/3.0.3     2. yml 매퍼 설정 확인#mybatis 설정mybatis: mapper-locations: - classpath:mapper//*.xml #MyBatis 매퍼 파일 위치를 설정합니다. 은 모든 디렉토리, *.xml 은 모든 XML 파일을 의미합니다. configuration: map-underscore-to-camel-case: true #데이터베이스의 언더스코어 네이밍(column_name)을 카멜 케이스(columnName)로 자동 매핑합니다. log-impl: org.apache.i..

설치 메뉴얼 2024.08.06

[SpringBoot] 10. DB 접근 기술 - MyBatis 설정

1. DB 접근 기술이란? 2. MyBatis란? 3. UserRepository - user.xmlpackage com.tenco.bank.repository.interfaces;import java.util.List;import org.apache.ibatis.annotations.Mapper;import com.tenco.bank.repository.model.User;// MyBatis 설정 확인// UserRepository 인터페이스와 user.xml 파일을 매칭시킨다.@Mapper // 반드시 선언해야 동작한다.public interface UserRepository { public int insert(User user); public int updateById(User user); pub..

Springboot 2024.08.06

[SpringBoot] 7. Exception Handler 처리

1. @ControllerAdvice와 @RestcontrollerAdvice(1) 개념 (2) 차이점 2. 코드(1) RedirectExceptionpackage com.tenco.bank.handler.Exception;import org.springframework.http.HttpStatus;import lombok.Getter;@Getter// 에러 발생 시에 여러 페이지로 이동시킬 때 사용 예정public class RedirectException extends RuntimeException{ private HttpStatus status; // throw new RedirectException(???,???); public RedirectException(String message,Http..

Springboot 2024.08.05

[SpringBoot] 6. 메인컨트롤러와 메인페이지 구현하기

1. 프레임워크와 라이브러리의 개념 2. IoC의 개념(제어의 역전 3. 프레임워크로 구현하기(1) 메인 컨트롤러(mainController.java)package com.tenco.bank.controller;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.GetMapping;@Controller // IoC의 대상(싱글톤 패턴으로 관리된다.)// IoC = inversion of controll (=제어의 역전)public class MainController { // REST API 기반으로 주소 설계 가능 // 주소 설계 // http://localhost:8080/mai..

Springboot 2024.08.05

[SpringBoot] 4. 모델링(1) - DB 모델링

1. 모델링의 개념* 데이터 베이스 모델링은 데이터 구조에 핵심을 둬야 한다! 2. ORM과 TRM 방식(1) ORM(Object-Relational Mapping)(2) TRM(Table-Relational Mapping) 3. DB 설계(1) DB 설계 쿼리-- 데이터베이스 생성-- mybankcreate database mybank;use mybank;-- 외래키 지정 안 함... (only 컬럼)-- 유저 테이블 설계create table user_tb( id int auto_increment primary key, username varchar(50) not null unique key, password varchar(100) not null, fullname varchar(50..

Springboot 2024.08.05