not-null property references a null or transient value

SoDEV·2025년 5월 28일

스프링 부트

목록 보기
12/17


인텔리제이 로그창

 [ERROR] o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class com.example.springEssential.data.dto.ProductDto]] with root cause 
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.example.springEssential.data.dto.ProductDto` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 2, column: 3]

시도

  1. Product 엔티티에 @Getter어노테이션 추가
  2. ProductDto클래스-@NoArgsConstructer 추가
    ->[ERROR]PropertyValueException: not-null property references a null or transient value: com.example.springEssential.data.entity.Product.stock

원인

service 계층에서
product.setPrice(productDto.getPrice()); product.setStock(product.getStock());setStock을 할때 다음과 같이 잘못입력했다. entity가 아닌 dto를 이용해서 stock값을 받아와야됨.
product.setStock(productDto.getStock())으로 변경

해결

profile
비가 와도 눈이 와도 파도를 향해서! 🌊🐢

0개의 댓글