Spring Boot 15

[Spring Boot] HTTP 통신 방식 과 REST의 개념

1. HTTP 통신 방식 1) GET Method - 주소창에 파라미터가 노출된다 - ex) www.localhost:8080/search?id=account&password=1234 - 브라우저에서 주소에 대한 캐시가 이루어지므로, 정보를 얻을 때 사용한다 2) POST Method - 주소 창에 파라미터가 노출되지 않는다. - ex) www.localhost:8080/search - 주소 창에 사용자의 요청 사항이 노출되지 않는다 - GET방식에서는 주소 길이 제한이 있지만 POST는 그보다 길게 사용 가능(제한 존재) - 브라우저가 주소 캐시를 하지 못하는 특성이 있다 - 주로 HTML, Ajax 통신할 때 사용 - @RequestBody와 자주 사용된다. (http통신의 post body에 dat..

Spring Boot 2020.07.04

[Spring Boot] 예외를 따로 처리하는 @ControllerAdvice

예외를 처리할 때 아래와 같이 try catch방식이 아니라 public class RestaurantNotFoundException extends RuntimeException { //예외처리 함수 public RestaurantNotFoundException(Long id){ super("Could not find restaurant" + id); } } @GetMapping("/restaurants/{id}") public Restaurant detail(@PathVariable("id") Long id){ try{ Restaurant restaurant = restaurantService.getRestaurant(id); //기본정보 + 메뉴정보 }catch(RestaurantNotFoundExc..

Spring Boot 2020.06.30

[SpringBoot] Lombok ToString 특정 필드 출력 안하는 법

ToString 하였을 때 phoneNumber 필드는 숨기려고한다. 방법은 2가지이다. 1. @ToString(exclude = 필드명) @Entity @Getter @Setter @ToString(exclude = "phoneNumber") public class Person { @Id @GeneratedValue //default 자동 생성 private Long id; private String name; private int age; private String hobby; private String bloodType; private String address; private LocalDate birthday; private String job; private String phoneNumber; ..

Spring Boot 2020.06.17

[Spring Boot] Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed) 오류 해결방법

./gradlew bootRun 으로 실행시 아래와 같은 오류 발생할 수 있다. FAILURE: Build failed with an exception. * What went wrong: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed) * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. 해결 방법 application.properties 에 org.gradle.daem..

Spring Boot 2020.06.16