방명록
- Spring Boot JWT Tutorial 1) 프로젝트 생성2023년 12월 24일 09시 03분 26초에 업로드 된 글입니다.작성자: 민발자728x90
Session 1 프로젝트 생성
1. 프로젝트 생성
1) 프로젝트 생성
2) IDE 설정
롬복 사용하기 때문에 Enble annotation pocessing 체크
2. rest API 테스트
1) hello API
@RestController @RequestMapping("/api") public class HelloController { @GetMapping("/hello") public ResponseEntity<String> hello() { return ResponseEntity.ok("hello"); } }
RestController : json을 반환하는 컨트롤러
RequestMapping : 들어온 요청을 매핑
GetMapping : HTTP Get요청을 매핑
ResponseEntity : HttpRequest에 대한 응답 데이터를 포함하는 클래스
ResponseEntity.ok() : 정상 요청이면(상태코드가 200 ok) 파라미터 반환
2) hello API 테스트 결과
Postman을 사용하여 /api/hello url로 get 요청 시 HTTP 상태 코드 401 Unauthorized 반환
728x90'공부 > Spring' 카테고리의 다른 글
[Spring] 스프링 DB 1편 6) 스프링과 문제 해결 - 예외 처리, 반복 (2) 2023.11.21 [Spring] 스프링 DB 1편 5) 자바 예외 이해 (2) 2023.11.20 [Spring] 스프링 DB 1편 4) 스프링과 문제 해결 - 트랜잭션(2) (0) 2023.11.19 [Spring] 스프링 DB 1편 4) 스프링과 문제 해결 - 트랜잭션(1) (0) 2023.11.18 [Spring] 스프링 DB 1편 3) 트랜잭션 이해(2) (0) 2023.11.17 다음글이 없습니다.이전글이 없습니다.댓글