본문 바로가기

Spring

(12)
[SpringBoot] Spring Security configuration 임포트 시 에러 해결 문제 상황 Spring Security를 적용하기위해 Security Config 파일을 생성하던 중이었다. public class SecurityConfig extends WebSecurityConfigurerAdapter { // 상속 클래스 오류! // 생략 } 위처럼 Security 설정을 위한 필수적인 코드를 작성하고 있는데 자꾸 WebSecurityConfigurerAdapter 클래스가 임포트되지 않았다. 계속 빨간 글자로 날 위협하고.. java lib path 추가해준다고 하고 그러는데.. 다 해도 뭔 소용이 없었다. 다른 security 내 library도 안되나 해서 import 해보는데 다 안됐다. implementation 'org.springframework.boot:spring..
[SpringBoot] IntelliJ 에서 Spring Boot Web 프로젝트 생성하기 [SpringBoot] IntelliJ 에서 Spring Boot 프로젝트 생성하기 1. File > New > Project... 클릭 2. New Project 화면에서 아래 단계 진행 Spring Initializr -> Java SDK 선택 -> [Next] Artifact 지정(프로젝트명이 됨) -> Java version 지정 -> [Next] 선택 Web -> Spring Web 체크 Next 계속 눌러서 완료하면 프로젝트 생성된다! 기본 구조 생성 완료!
[IntelliJ/Spring] 테스트 실행 에러 해결 (Build failed with an exception) intelliJ 환경에서 spring boot로 테스트 코드를 작성 후 실행하였는데 아래와 같은 에러가 발생했다. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':test'. > No tests found for given includes: [com.itevent.iteventapi.controller.AccountControllerTest.helloTest](filter.includeTestsMatching) 아래와 같이 해결하였다. Settings > Build, Excecution, Deployment > Build Tools > Gradle Run tests using - [IntelliJ..
[Spring] Bean property '필드명' is not readable or has an invalid getter method 에러 해결 에러 내용 Request 클래스의 validator 에러처리를 추가하고 있었는데 아래와 같은 에러를 발견하였다. Request processing failed; nested exception is org.springframework.beans.NotReadablePropertyException: Invalid property 'nickname' of bean class [AccountUpdateDto.Nickname]: Bean property 'nickname' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? getter/sette..
[Spring] ModelMapper Entity to DTO 변환 시 프로퍼티 null 해결 들어가며 API의 Response로 전달될 Object를 만들면서 Entity 를 DTO로 변환해야하는 경우가 생겼다. 여느 때처럼 DTO클래스에 Mapper로 매핑작업을 하는 of() 메서드를 만들었는데 json 응답 값이 null 파티였다. (😂NULL🎉....) 왜 나는 modelMapper, objectMapper, Jackson의 늪은 벗어날 수 없는걸까.. 거의 매일 찾아보는데 다음 날 되면 다시 리셋되는 나의 머릿 속,,😫 또 같은 실수를 반복하지 않기 위해 울면서작성해본다 광광..흑흑.. 문제 상황 Account 엔티티 객체 -> AccountResDto 응답용 객체 로 변환하고자 of 메서드를 제작하였다. @Getter public class AccountResDto { private s..
[SpringBoot] @ExceptionHandler 적용 시 HttpMediaTypeNotAcceptableException 에러 해결 에러를 처리하는 곳에서 에러가 났다...😱 (이것은.. 무한 에러 루프..?) Spring Boot에서 공통 익셉션을 처리하기 위해 @RestControllerAdvice, @ExceptionHandler를 사용하여 개발하고 있었다. 익셉션처리가 잘 되는지 확인하기 위해 service단에서 익셉션을 날렸다. 근데 읭? 원하는 에러가 나기 전에 아래와 같은 에러를 뱉었다. 분명 다른 분들의 글을 총집합하여 예제를 잘 따라한 것 같은데.. 🤷🏻‍♀️ 해결해보자...! 에러 내용 ExceptionHandlerExceptionResolver : Failure in @ExceptionHandler com.itevent.iteventapi.common.error.ControllerExceptionHandler#ha..
[SpringBoot] h2-console 웹 접근안될 때 해결 방법 Springboot에서 H2를 적용하고, 웹 콘솔 사용여부 true 처리하였는데 웹 접근이 안되는 상황을 겪었다. 찾아보니 원인은 아주 간단하지만 놓치기 쉬운 부분이었다. application.properties 의 h2 적용 상태 # 상단 생략 spring.datasource.url=jdbc:h2:~/test;AUTO_SERVER=TRUE spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password= spring.h2.console.enabled=true spring.h2.console.settings.web-allow-others=true spring.h2.console.pa..
[Spring/JPA] @DynamicUpdate, Validation 동시 적용 시 Validation 에러 해결 문제 User update 로직 내 원하는 필드만 업데이트 시도 시, 제약조건 걸린 컬럼의 에러 발생 상황 클래스 상단에 @DynamicUpdate 어노테이션이 붙여진 상태이다. @DynamicUpdate 어노테이션 : 전체 컬럼이 아닌 바뀐 값만 Update 한다. id를 키값으로 갖고, name, password만 수정될 값으로 매핑하여 받았다. Service의 update 로직 내에서 정상 업데이트 진행 시(save) Id값을 기준으로 수정 컬럼만 업데이트 할 거라고 예상했다. ConstraintViolationException: Validation faild for classes ~ 에러 발생 엔티티에 제약사항이 걸려있는 Email, Role 이 비어있고, Null이어서 익셉션 에러가 났다. 원인..