본문 바로가기

트러블슈팅

(18)
Redis Lock 적용 중 Lock은 적용되나 재고 처리가 제대로 되지 않음 제이미터 상으로 에러가 나지 않고 주문은 잘 생성되고, 테스트 코드도 잘 동작하지만 재고 차감이 제대로 이루어지지 않음 → 테스트는 서비스 메서드만 타고, 주문은 잘 생성되는 거 보면 서비스 메서드를 가기 전에 발생되는 문제 → 컨트롤러에서 Stock을 찾아준 것이 1차 캐싱되어 서비스 메서드에 있는 findStockById를 실행하지 않고 캐시되어 있는 stock을 그대로 가져옴 → 컨트롤러에서 Stock찾기를 빼주고 LockName을 productId로 변경 이전 코드 // Controller @PostMapping("/products/{productId}/orders") public ResponseEntity createOrder(@PathVariable Long productId, @Request..
엘라스틱서치 sort = "id" 적용시 에러 sort 기준을 id로 둘시(그냥 아무거나 기준을 주는순간) all shards fail을 뿜어댄다 @PageableDefault(size = 20, page = 1) Pageable pageable sort값을 빼서 해결 -> 근본적인 해결이 안됐음 왜 그런지 모르겠음
ElasticSearch 조건값을 주어도 무작위로 다 가져오는 현상 @RequiredArgsConstructor @Component public class RestaurantSearchRepositoryImpl{ private final ElasticsearchOperations elasticsearchOperations; public Page searchByCriteria(String restaurantName, String address, String category, Pageable pageable) { Criteria criteria = new Criteria(); if (!restaurantName.isEmpty()) { criteria.and("restaurant_name").contains(restaurantName); } if (!address.isEmpt..
로컬스토리지에 token이 저장이 안되는 현상 Login package com.challnege.delivery.global.jwt.handler; import com.challnege.delivery.domain.member.repository.MemberRepository; import com.challnege.delivery.global.jwt.jwt.JwtService; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; import org.springframework.beans.f..
resolved [org.springframework.web.httpmediatypenotsupportedexception: content-type 'multipart/form-data;boundary 이미지 업로드를 위해서 DTO와 MultipartFile을 동시에 전송하면 이러한 오류가 발생한다. @PostMapping public ResponseEntity createProduct(@RequestBody @Valid ProductPostDto postDto, @RequestParam List multipartFiles) { ProductResponseDto productResponseDto = productService.createProduct(postDto, multipartFiles); return new ResponseEntity(productResponseDto, HttpStatus.CREATED); } 해결방법 @PostMapping public ResponseEntity createPr..
securityconfig 인가 제대로 작동 안함 해결 @Configuration @EnableWebSecurity @RequiredArgsConstructor @EnableGlobalMethodSecurity(prePostEnabled = true) public class SecurityConfig { private final LoginService loginService; private final JwtService jwtService; private final AdminRepository adminRepository; private final ObjectMapper objectMapper; @Bean public PasswordEncoder passwordEncoder() { return PasswordEncoderFactories.createDeleg..
순환참조 해결 @JsonIgnoreProperties("lecture") private List commentList; @JsonIgnoreProperties 적용 후 해결
No validator could be found for constraint 'javax.validation.constraints.NotEmpty' validating type 'java.lang.Long'. No validator could be found for constraint 'javax.validation.constraints.NotEmpty' validating type 'java.lang.Long'. Check configuration for '**' with root cause . @NotEmpty는 String 타입에 사용하는 애노테이션으로 Long타입인 필드에 NotEmpty로 유효성 검사를 걸어버려서 생긴 에러. Long의 경우 @NotNull 정도를 사용해야한다.