2025/02/06 5

중앙식 예외 핸들러와 이를 이용한 오류 처리

112p ~ @RestControllerAdvice 클래스는 예외와 상태 코드 사이의 매핑을 제공. 카탈로그에 이미 있는 책 생성시 422(처리할 수 없는 개체), 존재하지 않는 책을 가져오려할 때는 404(찾을 수 없음), Book 객체에서 하나 이상의 필드가 잘못되었을 때는 400(잘못된 요청) 응답 반환. package com.polarbookshop.catalogservice.web;import com.polarbookshop.catalogservice.domain.BookAlreadyExistsException;import com.polarbookshop.catalogservice.domain.BookNotFoundException;import org.springframework.http.Htt..

데이터 유효성 검사

109p ~ 111p 유효성 검사를 해야할 조건은 아래와 같다. ISBN은 올바른 형식으로 정의되어야 한다(ISBN-10 or 13)제목, 저자, 가격은 반드시 있어야하고 가격은 0보다 큰 값이어야 한다.plugins { id 'java' id 'org.springframework.boot' version '3.4.1' id 'io.spring.dependency-management' version '1.1.7'}group = 'com.polarbookshop'version = '0.0.1-SNAPSHOT'java { toolchain { languageVersion = JavaLanguageVersion.of(17) }}repositories { mavenCentral()}dependencies { ..

스프링 MVC를 이용한 REST API 구현, 그리고 Httpie 설치와의 사투

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 넘나 멍청하게 ./gradlew bootRun 치고 왜 안되지...... 이러고 있다가 윈도우터미널인걸 깨닫...하 바보가태 윈도우면 gradlew.bat bootRun 으로 실행 근데 또 오류낫쥬...? ㅎㅎ.... 더보기11:12:27.135 [main] ERROR org.springframework.boot.SpringApplication -- Application run failed org.yaml.snakeyaml.scanner.ScannerException: mapping values are not allowed here  in 'reader', line 2, column 7:     server:           ^      ..

[SQL50] 1757. Recyclable and Low Fat Products

난이도: EASY 문제문제가 너무 쉬워서 5번 다시 읽음.더보기Table: Products +-------------+---------+ | Column Name | Type    | +-------------+---------+ | product_id  | int     | | low_fats    | enum    | | recyclable  | enum    | +-------------+---------+ product_id is the primary key (column with unique values) for this table. low_fats is an ENUM (category) of type ('Y', 'N') where 'Y' means this product is low fat a..

[Java] 20. Valid Parentheses

난이도: EASY문제더보기Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the same type. Example 1: Input: s = "()" Output: true Example 2: In..