[스프링] intellij - h2 database 1. build.gradle 파일에 dependencies 에 '...starter-data-jpa' 추가 2. application.yml 에 데이터베이스 주소 설정 jdbc:h2:men:testdb 설정을 안하면 run할때마다 주소가 변경됨 3. http:localhost:8070/h2-console/ 접속 jdbc url 에 jdbc:h2:mem:testdb 입력 4. h2 database 접속완료 Spring 2023.07.07
[스프링] Lombok - @Data package com.example.practice5.lombok.model; import lombok.Data; @Data public class Member { private Long id; private Integer age; } Delombok 하면... package com.example.practice5.lombok.model; public class Member { private Long id; private Integer age; public Member() { } public Long getId() { return this.id; } public Integer getAge() { return this.age; } public void setId(Long id) { this.id = id;.. Spring 2023.07.07
[스프링] Lombok - @Builder @Builder package com.example.practice5.lombok.model; import lombok.*; import org.springframework.web.util.pattern.PathPattern; import java.time.LocalDateTime; @Getter @Setter @AllArgsConstructor @NoArgsConstructor @RequiredArgsConstructor @ToString @Builder public class User { @NonNull private String name; @NonNull private String email; private LocalDateTime createAt; private LocalDateTime updat.. Spring 2023.07.07
[스프링] [java] Lombok annotation 사전준비 : 롬복 활성화 하기 어노테이션 사용 package com.example.practice5.lombok.model; import lombok.*; import org.springframework.web.util.pattern.PathPattern; import java.time.LocalDateTime; @Getter @Setter @AllArgsConstructor @NoArgsConstructor @RequiredArgsConstructor @ToString public class User { @NonNull private String name; @NonNull private String email; private LocalDateTime createAt; private LocalDateTi.. Spring 2023.07.07
[스프링] 예외처리 @ExceptionHandler package com.example.practice3.spring_exception.controller; import com.example.practice3.spring_exception.dto.User; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.MissingServletRequestParameterException; import org.springframework.web.bind.annotation.*; @Res.. Spring 2023.07.05
[스프링] Exception 처리하는 방법 Spring에서 Exception처리하는 방법 1. @ControllerAdvice: Global 예외 처리 및 특정 package / controller 예외처리 가능 2. @ExceptionHandler: 특정 controller 예외처리 가능 @ExceptionHandler [컨트롤러 어드바이스(ContorllerAdvice) 에서 에러 처리] package com.example.practice3.spring_exception.advice; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.MissingServletRequ.. Spring 2023.07.05