Java/Spring Boot18 HTTP 상태 코드 종류 예외처리 상태코드org.springframework.http.HttpStatusSpring에서 제공하는 HTTP 상태 코드(enum) 클래스[HttpStatus 공식 JavaDoc 보기 (Spring)]https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/HttpStatus.html주요 HTTP 상태 코드 종류200HttpStatus.OK성공201CREATED리소스 생성 완료 (POST 응답 등)204NO_CONTENT응답 본문 없음 (삭제 등)400BAD_REQUEST클라이언트 요청 오류 (잘못된 파라미터 등)401UNAUTHORIZED인증 실패 (로그인 안 됨 등)403FORBIDDEN권한 없음.. 2025. 3. 27. JWT & CRSF JWT 구성요소JWT는 세 부분으로 구성됩니다:xxxxx.yyyyy.zzzzzHeader.Payload.Signature각 부분은 Base64Url로 인코딩된 JSON 문자열입니다.1. Header (헤더)토큰의 타입과 서명 알고리즘 정보를 담습니다.{ "alg": "HS256", "typ": "JWT"}alg: 서명에 사용할 알고리즘 (예: HS256, RS256)typ: 토큰 타입 (보통 "JWT")2. Payload (페이로드, = claims)사용자 정보와 토큰의 의미 있는 데이터를 담는 핵심 부분입니다.{ "sub": "accessToken", "userId": 123, "email": "user@example.com", "role": "ADMIN", "iat": 1718780000.. 2025. 3. 25. [restartedMain] i.n.r.d.DnsServerAddressStreamProviders : Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS. ERROR 56522 --- [backend] [restartedMain] i.n.r.d.DnsServerAddressStreamProviders : Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS. Check whether you have a dependency on 'io.netty:netty-resolver-dns-native-macos'. Use DEBUG level to see the full stack: java.lang.UnsatisfiedLi.. 2025. 1. 30. [Spring Boot] email 전송하기 gmail 설정하기 서버 관련(Springboot) 클라이언트 관련(Next)gmail 설정하기gmail 가입 -> google 계정 -> 보안 -> 2단계 인증 설정 후 상단 계정 검색에서 '앱 비밀번호' 검색앱 비밀번호를 복사해 둔다.Server// build.gradledependencies { implementation 'org.springframework.boot:spring-boot-starter-mail'}# application.properties# mailspring.mail.host=smtp.gmail.comspring.mail.port=587spring.mail.username= 메일 주소 (메일@gmail.com)spring.mail.password= 앱 비밀번호 (띄어쓰기 지우기).. 2025. 1. 29. [SpringBoot] Thymeleaf 먼저, thymeleaf를 사용하기 위해서는 build.gradle에 추가한다.// build.gradledependencies { // thymeleaf implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect'}resources 폴더에 templates 폴더를 추가하고 이름.html 파일을 만들면 사용준비가 완료된다. th: 가 붙은 부분은 Java코드와 연결된다. Model 객체에 저장한 이름으로 읽을 수 있다. 제목 작성일시 .. 2024. 12. 25. [SpringBoot] Spring Test import static org.junit.jupiter.api.Assertions.assertEquals; ...중략 @Test void testJpa() { List all = this.questionRepository.findAll(); assertEquals(2, all.size()); Question q = all.get(0); assertEquals("sbb가 무엇인가요?", q.getSubject()); }// src/test/java/com.mysite.sbbimport java.time.LocalDateTime;import org.junit.jupiter.api.Test;import org.springframework.be.. 2024. 12. 25. [SpringBoot] H2database, JPA 설정과 사용법 @Test void testJpa() { Optional oq = this.questionRepository.findById(1); if(oq.isPresent()) { Question q = oq.get(); assertEquals("sbb가 무엇인가요?", q.getSubject()); } }ORM(Object-Relational Mapping): ORM은 SQL을 사용하지 않고 데이터베이스를 관리할 수 있는 도구, DBMS의 종류에 관계없이 일관된 자바 코드를 사용할 수 있어서 프로그램을 유지·보수하기가 편리하다. JPA(Java Persistence API): 하이버네이트는 JPA의 인터페이스를 구현한 실제 .. 2024. 12. 22. [SpringBoot] Annotation Appliction 파일package com.mysite.sbb;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class SbbApplication { public static void main(String[] args) { SpringApplication.run(SbbApplication.class, args); }}@SpringBootApplication : 프로젝트명 + Application.java 파일내 클래스에 반드시 있어야하며, 이를 통해 스프링 부트 어플리케이션을 실행한다.C.. 2024. 12. 22. [SpringBoot] 기본 파일 src/main/java : java 파일을 저장Application.java 파일//src/main/java/com.mysite.sbb.SbbApplication.javaimport org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class SbbApplication { public static void main(String[] args) { SpringApplication.run(SbbApplication.class, args); }}@SpringBootApplication : 프로젝트명 + Appl.. 2024. 12. 22. 이전 1 2 다음