본문 바로가기

오답노트

(6)
ModelMapper 사용 시 Setter 쓰기 싫을 때 Entity 와 Dto 매핑 시에 필드들을 하나하나 나열하기도 하지만, 라이브러리를 사용하여 진행하기도 하는 것 같다. 그래서 저번에 배워본 ModelMapper 를 이용하여 쉽게 변환하려 했다. ModelMapper ModelMapper - Simple, Intelligent, Object Mapping. Why ModelMapper? The goal of ModelMapper is to make object mapping easy, by automatically determining how one object model maps to another, based on conventions, in the same way that a human would - while providing a simple, ..
java.util.ConcurrentModificationException 발생 Cache 기능을 담당하는 Map 을 Service 에 필드값으로 갖고 두 메서드에서 접근한다. 검색(search) 후 데이터들을 업데이트(updateAllSearch) 한다. ConcurrentModificationException 이 발생했다. This exception may be thrown by methods that have detected concurrent modification of an object when such modification is not permissible. 이 예외는 오브젝트의 허가되지 않은 동시 수정이 감지될 때 발생합니다. 루프 문 안에서 해당 객체를 삭제 했기 때문에 발생 remove 시행하지 않고 덮어쓰기 시행 또는 HashMap 대신 ConcurrentHash..
@Builder 사용시 초기화할 필드가 있다면 @Builder will ignore the initializing expression entirely. If you want the initializing expression to serve as default, add @Builder.Default. If it is not supposed to be settable during building, make the field final. @Builder 는 초기화 표현을 완전히 무시한다. 초기화 하고 싶으면 @Builder.Default 를 사용해. 아니면 final 쓰면돼 라고 합니다. plating 이란 필드의 초기값을 정해주고, delete 라는 메서드를 통해 변경할 여지가 있으므로 @Builder.Default 를 넣었습니다.
저장되지 않은 Entity 객체를 포함한 Entity 저장했을 때 org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: 오브젝트가 저장되지 않은 임시 인스턴스를 참조합니다. 플러싱 전에 임시 객체를 저장하세요. 저장한 IssueMember 가 아닌 생성한 IssueMember 여서 그랬다. 저장한 IssueMember 를 사용하니 에러 해결
TestRestTemplate webEnvironment 오류 TestRestTemplate - org.springframework.boot.test.web.client.TestRestTemplate @SpringBootTest - org.springframework.boot.test.context.SpringBootTest TestRestTemplate 을 통하여 api를 호출하고 그 결과값을 확인하기 위해 테스트를 작성한다. 이런 엄청나게 긴 오류가 나타났다. 다음 오류 내용이다. Unsatisfied dependency expressed through field 'restTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifyi..
@Entity, @Builder 함께 사용할 때 @Entity - javax.persistence.Entity @Builder - lombok.Builder 클래스 정의 오류 메시지 @Builder 만 정의 @Entity 와 @AllArgsConstructor 만 정의 @Entity 는 no-args 가 필요하고 @Builder 는 all-args 가 필요하다. 맨위로 다시 가보면 이 때 @Builder 가 만들 all - args constructor 가 생성이 안되는 것 같다. - 찾았음 해석하면 이 생성자는 생성자를 작성하지 않았고 명시적인 @XArgsConstructor 주석도 추가하지 않은 경우에만 생성됩니다. 라고 합니다. 그러니 NoArgsConstructor 를 사용하게 되면 꼭 @AllArgsConstructor 를 명시해주자. htt..