inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

핸들러와 어댑터의 정확한 구분법?이 뭘까요

미해결

스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술

핸들러는 Request에 들어오는 파라미터?링크? 에 따라 처리하는 모든 클래스?메소드? 들을 핸들러라고 보면 될까요 ? 왜 @RequestMapping, Controller 인터페이스와 같이 우선순위가 나누어지는 것인가요? 같은 파라미터에 대한 핸들러가 많으면 첫번째로 잡는건가요 ?? 그렇다면 같은 파라미터에 대해 여러가지 핸들러가 있다면 우선순위가 높은 핸들러를 선택하게 되는 것인가요 ?? 이때 클래스마다 String, ModelAndView 등등 무엇을 return 할지 모르기 때문에 DispatcherServlet에서 자유롭게 사용할 수 없는 불편함이 있고 이것들을 공통적으로 ModelAndView로 return 하게끔 도와주는게 어댑터인가요 ?? 강의를 보며 직접 타이핑도 했는데 헷갈립니다 ㅠㅠ..

  • MVC
  • spring
댓글 1 좋아요 2 조회수 567

갑작스런 오류..;

미해결

스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술

v3까지 잘 작동되다가 v4부터 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 라는 오류가 뜨면서 서버가 안켜집니다 ㅠ 자바11, 인텔리제이 재설치도 해보고 구글링도 다 해봤는데 고쳐지질 않아서 이전 프로젝트 실행해보니 이건 잘됐고 강의자료에 있는 프로젝트도 시도해보니 안되네요.. 어떻게 해야 고칠 수 있을까요 ㅠ

  • MVC
  • spring
댓글 1 좋아요 0 조회수 12604

api 예외 처리

미해결

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 여기에 질문 내용을 남겨주세요. 좋은 강의 감사합니다 :) 제가 이해하기로는 테스트를 하기 위해서 ApiExceptionController 에서 파라미터로 받은 것 같은데요. 실무에서는 어떤 방식으로 하는지 궁금해서 질문 올렸습니다.. 예시 코드 있으시면 깃허브나 코드 복사 등 으로 답글 부탁드립니다 @RestController public class ApiExceptionController { @GetMapping ( "/api/{id}" ) public MemberDto getMember ( @PathVariable ( "id" ) String id ) { if ( id . equals ( "ex" ) ) { throw new RuntimeException ( "잘못된 사용자" ) ; } if ( id . equals ( "bad" ) ) { throw new IllegalArgumentException ( "잘못된 입력 값" ) ; } if ( id . equals ( "user-ex" ) ) { throw new UserException ( "사용자 오류" ) ; } } } @ExceptionHandler public ResponseEntity<ErrorResult> userExHandle(UserException e) { log.error("[exceptionHandle] ex", e); ErrorResult errorResult = new ErrorResult("USER-EX", e.getMessage()); return new ResponseEntity<>(errorResult, HttpStatus.BAD_REQUEST);

  • MVC
  • spring
fe00045 댓글 1 좋아요 1 조회수 238

세션 관련 이해한 내용이 맞는지 확인부탁드립니다

미해결

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

1명의 유저에게 1개 세션(저장소) & 1개 세션 Key(JSESSIONID) 할당 다수의 세션을 갖는 하나의 세션 저장소(Tomcat이 관리) 다수의 키(SessionConst.LOGIN_MEMBER etc..) & 상응하는 값(loginMember etc..) 을 갖는 하나의 세션 세션 내용이 이해가 잘 안돼서 질문글들을 정독해보고 내린 결론인데 잘 이해했는지 혹시 잘못 이해한게 있는지 확인해주시면 감사하겠습니다 추가로 이게 맞다면 이전에 만든 SessionManager와의 차이가 One Session for Multi User ( SessionManager) vs One Session for One User (HttpSession) 라고 생각했는데 괜찮을까요?

  • MVC
  • spring
이시혁 댓글 1 좋아요 10 조회수 508

ModelView가 어떻게 흘러가는지와 model의 역할이 궁금합니다

미해결

스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술

Q1. 처음 new-form 에 들어오게 되면 FrontControllerServleV3에서는 Http 메세지 바디에 있는 파라미터들을 만들어서 paramMap 으로 만들고, 이것들 MemberFormControllerV3에 넘겨줄거고 여기서 "new-form"이라는 String을 가진 ModelView를 리턴받는 mv가 생기고, 이 mv.getViewName 해서 나오는 viewName은 논리이름이기 때문에 viewResolver로 상대 이름으로 바꿔주고, 이것은 MyView에 있는 render로 보내서 new-form 화면이 뜨게 되는 것인가요 ?? Q2. 그 후 MEmberListControllerV3, MemberSaveControllerV3 에서 ModelView에 있는 HashMap으로 구현 된 model에 members와 member를 넣어주는데 넣는 이유가 궁금합니다. 실제로는 memberRepository 에 저장하고, findAll를 하기때문에 사실상 MemberRepository와 ModelView에 있는 Model은 항상 같은 것 아닌가요? 맞다면 왜 굳이 2가지의 객체를 만들어서 사용하는지가 궁금합니다.

  • MVC
  • spring
댓글 1 좋아요 1 조회수 548

경로 질문드립니다.

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

안녕하세요. @GetMapping("/hello") public void hello(Model model){ model.addAttribute("data", "hello!"); } 웹 브라우저에서 hello 경로로 접근할 때 컨트롤러에서 리턴 값으로 문자를 반환하면 뷰 리졸버가 화면을 찾아서 처리한다고 하셨는데 return 반환값이 없는 void로 해도 접근이 가능해서요. hello 경로에 접근하면 스프링 내부에서 resources -> static -> templates 순서대로 hello.html이 있는지 확인하는게 아닌가 싶어서 질문드립니다!

  • MVC
  • java
  • spring
  • spring-boot
댓글 3 좋아요 1 조회수 362

robomongo설치 관련 질문

미해결

남박사의 파이썬으로 실전 웹사이트 만들기

선생님 안녕하심까 지금 강의를 보면서 설치중인데 mongodb는 설치 완료 했습니다만 robomongo 설치과정에서 저는 선택지가 Studio 3T 밖에 없는데 이걸로 설치해도 될런지요?

  • python
김민수 댓글 2 좋아요 1 조회수 391

MessageSource를 ms로 바꾸면 Could not autowire라고 나옵니다.

해결됨

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

제목과 같이 MessageSource 변수명을 ms로 바꾸면 빨간줄이 나오는데 어떻게 해결해야 하나요? 강의 소스를 열어도 똑같이 빨간줄이 나옵니다.ㅜㅠ @Aotuwired위에 @Qualifier ( "messageSource" ) 를 하면 되기는 하는데 왜 저는 @Qualifier을 해야 되는 걸까요?

  • spring
  • MVC
lwisekiml 댓글 1 좋아요 1 조회수 596

소소한 궁금증. response.setCharacterEncoding("utf-8"); 질문

해결됨

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

@Slf4j public class UserHandlerExceptionResolver implements HandlerExceptionResolver { private final ObjectMapper objectMapper = new ObjectMapper() ; @Override public ModelAndView resolveException (HttpServletRequest request , HttpServletResponse response , Object handler , Exception ex) { try { if (ex instanceof UserException) { log .info( "UserException resolver to 400" ) ; String acceptHeader = request.getHeader( "accept" ) ; response.setStatus(HttpServletResponse. SC_BAD_REQUEST ) ; if ( "application/json" .equals(acceptHeader)) { Map<String , Object> errorResult = new HashMap<>() ; errorResult.put( "ex" , ex.getClass()) ; errorResult.put( "message" , ex.getMessage()) ; String result = objectMapper .writeValueAsString(errorResult) ; response.setContentType( "application/json" ) ; response.setCharacterEncoding( "utf-8" ) ; response.getWriter().write(result) ; return new ModelAndView() ; } else { //TEXT/HTML return new ModelAndView( "error/500" ) ; } } } catch (IOException e) { log .error( "resolver ex" , e) ; } return null; } } mvc 1편에서 ContentType : application/json은 원래 utf-8을 쓰게 되어 있어서 charset=utf-8 즉, response.setCharacterEncoding("utf-8"); 는 의미 없는 파라미터가 추가되는 것이라고 하셨는데 여기서 response.setCharacterEncoding("utf-8"); 코드를 쓴 다른 이유가 있는 건가요 ?

  • spring
  • MVC
relate16 댓글 1 좋아요 2 조회수 625

DB없이 데이터 저장이 어떻게 가능한지 궁금합니다.

해결됨

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

ㄱ학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 안 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 강사님, 안녕하세요. 강의 정말 잘 듣고 있습니다. 스프링 서버만 구현하여서 데이터가 저장되는데, 이것이 어떻게 가능한지 궁금합니다. 답변 부탁드립니다. 감사합니다.

  • DB없이
  • spring
  • 가능한이유
  • MVC
쿠카이든 댓글 2 좋아요 0 조회수 2095

새 탭으로 이미지 열기 질문입니다.

해결됨

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

강의내용중 31:24초 부분에 해당하는 질문입니다. 다른 사이트 이미지를 마우스 우클릭후, '새탭으로 이미지 열기'로 보면 제대로 이미지가 새탭으로 출력이되서 보이는데, 이 프로젝트 코드는 새 탭으로 이미지 열기를 사용하는데 31:20초 /items/1 경로의 이미지처럼 나오지않고 문자형태로 출력이되는지 궁금합니다. 또한 이처럼 31:24초처럼 이미지가 문자형태로 출력되지 않고 다른사이트(구글,네이버)처럼 새탭으로 이미지를 열어도 정상적으로 이미지가 출력되게 하기위해선 어떻게 해야하나요?

  • MVC
  • spring
김태홍 댓글 1 좋아요 0 조회수 1203

해킹의 가능성에 대해 질문있습니다

미해결

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

세션 과정을 위의 표와 같이 이해했습니다. 영한님께선 세션Id가 털려도 여기에는 중요한 정보가 없다. 즉 털려도 상관없다라는 식으로 말씀하셨는데, 위 표와 같이 제가 이해한게 맞다면 결국 해커가 세션 키만 안다면 해킹을 할 수 있는게 아닌가?라고 생각이 들었습니다. 맞는 방식인지는 모르겠으나 테스트를 해봤습니다 두 개의 창을 띄워 각 다른 아이디로 로그인 했습니다. 표 처럼 B의 세션키를 A에 적용했을 때 B로 바뀌는 모습을 확인할 수 있었습니다. 근데 이게 될 때도 있고 안 될 때도 있습니다.. 정확한 이유를 모르겠네요 물론 해킹을 100% 막을 순 없겠지만 생각보다 쉽게 털리는 것이 아닌지 의문점이 생겼는데, 제가 무엇을 잘못 알고있는걸까요?

  • MVC
  • spring
민혁 댓글 1 좋아요 1 조회수 315

경로는 찾으나 에러가뜹니다

미해결

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

이미지는 엑박으로 표기. ->새탭에서 이미지열기시, 나오는경로- http://localhost:8080/images/C:/Users/계정/springfile/images/c3a2eedd-4364-4f3f-a275-a800512e4949.png 파일다운로드 클릭시 경로와 에러페이지, http://localhost:8080/attach/C:/Users/계정/springfile/uploadfiles/9aa381e7-6b8d-412a-bf86-28caf5b29010.pdf 으로 됩니다. ---- save시 컴퓨터 경로에 사진, 파일이 저장이되고 db에도 잘 저장됩니다.. 코드 <img th :each ="imageFile : ${board.attachFiles}" th :if ="${imageFile.attachType.toString().equals('IMAGE')}" th :src ="|/images/${imageFile.storeFileName}|" width ="300" height ="300" style ="margin-right: 5px" /> <a th :each ="uploadFile : ${board.attachFiles}" th :if ="${uploadFile.attachType.toString().equals('FILE')}" th :href ="@{/attach/{filename}(filename=${uploadFile.storeFileName}, originName=${uploadFile.uploadFileName})}" th :text ="${uploadFile.uploadFileName}" style ="margin-right: 5px" /><br/> @ResponseBody @GetMapping ( "/images/{filename}" ) public Resource processImg ( @PathVariable String filename) throws MalformedURLException { return new UrlResource( "file:" + fileStore .getFullPath(filename , AttachType. IMAGE )) ; @GetMapping ( "/attach/{filename}" ) public ResponseEntity<Resource> processAttaches ( @PathVariable String filename , @RequestParam String originName) throws MalformedURLException { UrlResource resource = new UrlResource( "file:" + fileStore .getFullPath(filename , AttachType. FILE )) ; String encodedUploadFileName = UriUtils. encode (originName , StandardCharsets. UTF_8 ) ; String contentDisposition = "attachment; filename= \" " + encodedUploadFileName + " \" " ; return ResponseEntity. ok () .header(HttpHeaders. CONTENT_DISPOSITION , contentDisposition) .body(resource) ; }

  • MVC
  • spring
댓글 1 좋아요 0 조회수 419

@Transactional 넣었을때 문제

해결됨

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

[질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예) [질문 내용] 여기에 질문 내용을 남겨주세요. 강의내용대로 @Transactional 넣고 스프링부트띄워서 테스트를 돌리면 rollback이 바로되는게 아니라 좀 지나서 되는것 같더라구요 회원가입 테스트 돌리고 디비에서 member조회 해보면 인서트가 되어있고 한번더 조회하면 그때 사라지더라구요 그것 때문에 회원가입과 중복회원 따로 돌리면 되긴하는데 전체 테스트를 돌리면 중복회원예외에서 실패가 납니다. 어떻게 해야될까요..?

  • spring
  • MVC
  • spring-boot
  • java
알닉 댓글 1 좋아요 0 조회수 362

(request, response)

미해결

스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술

안녕하세요. forward(request, response) 할때, process(request, response) 할때 괄호안에 (request, response) 보내 줍니다. 이거에 대한 자세한 이유를 모르겠습니다. 그 메서드 안에 매개변수로 HttpServletRequest request, HttpServletResponse response) 를 받기 위해서 이고, 이, request, response 가 웹 브라우저에서의 요청과 응답을 해주기 위해? 자세히 설명을 못하겠어서 이렇게 질문 올립니다.

  • MVC
  • spring
혜민 댓글 1 좋아요 0 조회수 472

IsPrime 함수에서 for문 범위 질문 드립니다.

미해결

파이썬 알고리즘 문제풀이 입문(코딩테스트 대비)

def isPrime ( x ): ''' 소수인지 판별하는 함수 ''' if x == 1 : return False for i in range ( 2 , x // 2 + 1 ): if x % i == 0 : return False else : return True 위 for문에서 범위가 2부터 x를 2로나눈 몫까지 반복되는데, 예시로 들어주신 16의 경우, i가 2,3,4,5,6,7,8까지 반복문이 돌게 됩니다. 그런데 마지막 8의 경우는 2로 나눴을 때 이미 2*8=16으로 한번 나눠지게 되니 for문에 포함이 안되어도 될 것 같은데 아닌가요? range의 범위가 range(2,x//2) 로 수정되어야 할 것 같은데, 맞는건지 궁금합니다.

  • python
  • 코테 준비 같이 해요!
임나래 댓글 3 좋아요 0 조회수 372

500에러가 납니다.

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

왜 에러가 나오는지 모르겠습니다. Controller에서 Mapping 할 때 그냥 hello로 하면 404가 나오고 /hello 로 하게 되면 500 에러가 나오게 됩니다. 022-05-04 12:15:15.062 ERROR 5008 --- [nio-8080-exec-9] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template [hello!], template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause org.thymeleaf.exceptions.TemplateInputException: Error resolving template [hello!], template might not exist or might not be accessible by any of the configured Template Resolvers at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE] at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE] at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1098) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE] at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1072) ~[thymeleaf-3.0.15.RELEASE.jar:3.0.15.RELEASE] at org.thymeleaf.spring5.view.ThymeleafView.renderFragment(ThymeleafView.java:366) ~[thymeleaf-spring5-3.0.15.RELEASE.jar:3.0.15.RELEASE] at org.thymeleaf.spring5.view.ThymeleafView.render(ThymeleafView.java:190) ~[thymeleaf-spring5-3.0.15.RELEASE.jar:3.0.15.RELEASE] at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1401) ~[spring-webmvc-5.3.19.jar:5.3.19] at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1145) ~[spring-webmvc-5.3.19.jar:5.3.19] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1084) ~[spring-webmvc-5.3.19.jar:5.3.19] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.19.jar:5.3.19] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.19.jar:5.3.19] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.19.jar:5.3.19] at javax.servlet.http.HttpServlet.service(HttpServlet.java:655) ~[tomcat-embed-core-9.0.62.jar:4.0.FR] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.19.jar:5.3.19] at javax.servlet.http.HttpServlet.service(HttpServlet.java:764) ~[tomcat-embed-core-9.0.62.jar:4.0.FR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.62.jar:9.0.62] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.19.jar:5.3.19] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.19.jar:5.3.19] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.19.jar:5.3.19] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.19.jar:5.3.19] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.19.jar:5.3.19] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.19.jar:5.3.19] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.62.jar:9.0.62] at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]

  • spring
  • MVC
  • java
  • spring-boot
황경훈 댓글 1 좋아요 0 조회수 1143

스프링 데이터 JPA 오류

미해결

스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] SpringConfig에서 참조를 바꿔주었는데도 SpringDataJpa~~interface를 읽지 못하고 MemoryMemberRepository의 성분을 읽어오는데 이를 어떻게 해결해야할까요?? 추가로 MemberServiceIntegrationTest에서 회원가입과 중복회원예외도 제대로 작동하지 않습니다. 19:37:47.883 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate] 19:37:47.919 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)] 19:37:48.027 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [hello.hellospring.service.MemberServiceIntegrationTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper] 19:37:48.055 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [hello.hellospring.service.MemberServiceIntegrationTest], using SpringBootContextLoader 19:37:48.066 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [hello.hellospring.service.MemberServiceIntegrationTest]: class path resource [hello/hellospring/service/MemberServiceIntegrationTest-context.xml] does not exist 19:37:48.068 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [hello.hellospring.service.MemberServiceIntegrationTest]: class path resource [hello/hellospring/service/MemberServiceIntegrationTestContext.groovy] does not exist 19:37:48.069 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [hello.hellospring.service.MemberServiceIntegrationTest]: no resource found for suffixes {-context.xml, Context.groovy}. 19:37:48.071 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [hello.hellospring.service.MemberServiceIntegrationTest]: MemberServiceIntegrationTest does not declare any static, non-private, non-final, nested classes annotated with @Configuration. 19:37:48.201 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [hello.hellospring.service.MemberServiceIntegrationTest] 19:37:48.389 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [C:\Users\tjfgh\Desktop\spring\hello-spring\src\main\target\classes\hello\hellospring\HelloSpringApplication.class] 19:37:48.412 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration hello.hellospring.HelloSpringApplication for test class hello.hellospring.service.MemberServiceIntegrationTest 19:37:48.743 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [hello.hellospring.service.MemberServiceIntegrationTest]: using defaults. 19:37:48.744 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener] 19:37:48.789 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@50de186c, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@3f57bcad, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@1e8b7643, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@51549490, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@71e9ebae, org.springframework.test.context.support.DirtiesContextTestExecutionListener@73d983ea, org.springframework.test.context.transaction.TransactionalTestExecutionListener@36a5cabc, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@432038ec, org.springframework.test.context.event.EventPublishingTestExecutionListener@7daa0fbd, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@42530531, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@5a3bc7ed, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@181e731e, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@35645047, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@6f44a157, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@6bc407fd] 19:37:48.796 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@3bd323e9 testClass = MemberServiceIntegrationTest, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@39ac0c0a testClass = MemberServiceIntegrationTest, locations = '{}', classes = '{class hello.hellospring.HelloSpringApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@2bfc268b, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@10163d6, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@247d8ae, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@6c130c45, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@3fb1549b, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@7225790e], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true]], class annotated with @DirtiesContext [false] with mode [null]. . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.6.5) 2022-05-03 19:37:49.636 INFO 19392 --- [ main] h.h.s.MemberServiceIntegrationTest : Starting MemberServiceIntegrationTest using Java 12 on DESKTOP-U5FU35V with PID 19392 (started by tjfgh in C:\Users\tjfgh\Desktop\spring\hello-spring) 2022-05-03 19:37:49.637 INFO 19392 --- [ main] h.h.s.MemberServiceIntegrationTest : No active profile set, falling back to 1 default profile: "default" 2022-05-03 19:37:51.022 INFO 19392 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 2022-05-03 19:37:51.159 INFO 19392 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 111 ms. Found 1 JPA repository interfaces. 2022-05-03 19:37:52.256 INFO 19392 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default] 2022-05-03 19:37:52.365 INFO 19392 --- [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.7.Final 2022-05-03 19:37:52.716 INFO 19392 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 2022-05-03 19:37:54.441 INFO 19392 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting... 2022-05-03 19:37:54.593 INFO 19392 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed. 2022-05-03 19:37:54.641 INFO 19392 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.SQLServer2012Dialect Hibernate: drop table member Hibernate: create table member (id bigint identity not null, name varchar(255), primary key (id)) 2022-05-03 19:37:55.773 INFO 19392 --- [ main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform] 2022-05-03 19:37:55.787 INFO 19392 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2022-05-03 19:37:57.000 WARN 19392 --- [ main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 2022-05-03 19:37:57.629 INFO 19392 --- [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page: class path resource [static/index.html] 2022-05-03 19:37:58.306 INFO 19392 --- [ main] h.h.s.MemberServiceIntegrationTest : Started MemberServiceIntegrationTest in 9.396 seconds (JVM running for 12.408) 2022-05-03 19:37:58.363 INFO 19392 --- [ main] o.s.t.c.transaction.TransactionContext : Began transaction (1) for test context [DefaultTestContext@3bd323e9 testClass = MemberServiceIntegrationTest, testInstance = hello.hellospring.service.MemberServiceIntegrationTest@788d9139, testMethod = 회원가입@MemberServiceIntegrationTest, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@39ac0c0a testClass = MemberServiceIntegrationTest, locations = '{}', classes = '{class hello.hellospring.HelloSpringApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@2bfc268b, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@10163d6, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@247d8ae, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@6c130c45, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@3fb1549b, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@7225790e], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true, 'org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]]; transaction manager [org.springframework.orm.jpa.JpaTransactionManager@4c7f2fdb]; rollback [true] Hibernate: select member0_.id as id1_0_, member0_.name as name2_0_ from member member0_ where member0_.name=? Hibernate: insert into member (name) values (?) 2022-05-03 19:37:59.177 INFO 19392 --- [ main] o.s.t.c.transaction.TransactionContext : Rolled back transaction for test: [DefaultTestContext@3bd323e9 testClass = MemberServiceIntegrationTest, testInstance = hello.hellospring.service.MemberServiceIntegrationTest@788d9139, testMethod = 회원가입@MemberServiceIntegrationTest, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@39ac0c0a testClass = MemberServiceIntegrationTest, locations = '{}', classes = '{class hello.hellospring.HelloSpringApplication}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.actuate.metrics.MetricsExportContextCustomizerFactory$DisableMetricExportContextCustomizer@2bfc268b, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@10163d6, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@247d8ae, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@6c130c45, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@3fb1549b, org.springframework.boot.test.context.SpringBootTestArgs@1, org.springframework.boot.test.context.SpringBootTestWebEnvironment@7225790e], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true, 'org.springframework.test.context.event.ApplicationEventsTestExecutionListener.recordApplicationEvents' -> false]] 2022-05-03 19:37:59.202 INFO 19392 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2022-05-03 19:37:59.207 INFO 19392 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2022-05-03 19:37:59.230 INFO 19392 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. Process finished with exit code 0

  • spring
  • MVC
  • spring-boot
  • java
댓글 1 좋아요 0 조회수 335

검증 로직이 들어가는 계층

미해결

스프링 MVC 2편 - 백엔드 웹 개발 활용 기술

안녕하세요. BindingResult를 배우기 전에는 검증 로직을 작성할 때 Service에 작성을 했는데, BindingResult를 도입하고 나서부터는 Controller에 검증 로직이 들어가는데, 그렇다면 검증 로직이 들어가야 하는 부분이 이제는 Controller가 되는건가요? Controller는 모델과 뷰의 중간 역할을 하고 Service에서 비즈니스 로직을 처리한다고 하면, 검증 로직이 service에 들어가야 할 것 같은데 이 부분이 조금 헷갈리네요..

  • bindingresult
  • MVC
  • 검증
  • spring
jhjikhsdsdw 댓글 1 좋아요 0 조회수 361

인기 태그

인프런 TOP Writers

주간 인기글