반응형 반응형 전체 글130 반응형 java.util.NoSuchElementException: No value present //error 코드 Repository.findById(id).get() //orElse 해서 null을 넣어준다 그럼 에러가 사라짐 굳굳 Repository.findById(id).orElse(null); 2022. 6. 22. 스프링 서버 경로 구하기 //getRealPath() : 실제 톰캣이 돌아가고 있는 컴퓨터에서 그 곳의 절대 주소값 String rootPath = request.getSession().getServletContext().getRealPath("/"); //저장경로 1 String uploadPath = rootPath + "upload" ; 2 String uploadPath = request.getServletContext().getRealPath("/upload"); File path = new File(""); System.out.println(path.getAbsolutePath()); new File("").getAbsolutePath()+"/static/upload" 2022. 6. 15. SptringBoot Rest Api Exception @RestControllerAdvice : Exception 발생 시 JSON으로 반환받기 위하여 생성합니다. @ExceptionHandler: Bean에서 발생하는 에러를 잡아 처리합니다 전역의 예외를 잡긴하되 패키지 단위로 제한 할 수 도 있다. @RestControllerAdvice("com.example.demo.login.controller") @RestControllerAdvice(basePackages = "com.spring2.nyong.api") @RequiredArgsConstructor @RestControllerAdvice(basePackages = "com.spring2.nyong.api") public class ExceptionAdvice { private final Respo.. 2022. 5. 31. java.lang.IllegalStateException: No primary or default constructor found for interface org.springframework.data.domain.Pageable swagger 혹은 webConfig 에서 WebMvcConfigurationSupport extends로 받아 addResourceHandlers를 오버라이드 했을 때 이러면 WebAutoConfiguration이 MVC를 구성해 주지 않는다. 파라미터로 들어온 Pageable을 자동으로 init해주는 리졸버는 PageableHandlerMethodArgumentResolver인데, WebAutoConfiguration에서 추가해 주기 때문에 WebMvcConfig를 사용하려면 따로 추가해 주어야 한다. 해결 : 나는그냥 extends WebMvcConfigurationSupport 말고 implements WebMvcConfigurer 이거로 받았다 2022. 5. 24. 이전 1 ··· 10 11 12 13 14 15 16 ··· 33 다음 반응형