묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
이 질문에서 궁금한 것 이 있습니다.
https://www.inflearn.com/course/lecture?courseSlug=%EC%8A%A4%ED%94%84%EB%A7%81-mvc-2&unitId=83332&tab=community&category=questionDetail&q=379787 이분 질문처럼 쿠키네임이 항상 같은데 같은 쿠키네임에 sessionid가 다른것이 여러개라고 이해하면 되나여?? 만약 그렇다면 어떻게 작동하는지 이해가 되지 않습니다.
-
미해결스프링 핵심 원리 - 기본편
Controller 를 왜 사용했는지 궁금합니다!
[질문 템플릿]1. 강의 내용과 관련된 질문인가요? 예2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? 예3. 질문 잘하기 메뉴얼을 읽어보셨나요? 예[질문 내용]안녕하세요 :)빈 스코프 - request 스코프 예제 만들기 10:23에서 LogDemoController 클래스를 만드실 때 @Component가 아닌 @Controller를 사용하셨는데 어떤 이유로 인해 컴포넌트 대신 컨트롤러를 사용하셨는지 궁금합니다!추가로 두 기능들의 사용 용도의 차이점도 궁금합니다!강의 잘 보고 있습니다 영한님 ㅎㅎ 감사합니다.
-
미해결따라하며 배우는 리액트 네이티브 기초
계속 npx react-native run-ios 가 안됩니다ㅠㅠ
현재 계속 이런 창이 뜨는데요..엑스포로 실습할 때는 잘만 되다가 거의 다 와서 run-ios 까지 하니까 여기서부터 이렇게 뜨고 잘 안되네요최대한 방법을 스스로 찾아보려고 했는데 혹시 해결방법이 있을까요?npx react-native run-ios --simulator='iPhone 14 Pro (16.0)'이렇게는 잘 됐습니다!
-
해결됨코딩테스트 [ ALL IN ONE ]
root == p 를 비교하는법?
강사님의 풀이방법을 보면class Solution(object): def lowestCommonAncestor(self, root, p, q): left = self.lowestCommonAncestor(root.left, p, q) right = self.lowestCommonAncestor(root.right, p, q) if root == p or root == q: return root elif left and right: return root return left or right여기서 root.value == p가 아니라 어떻게 root == p로 비교할 수 있는 지 궁금합니다.아래는 제가 푼 방식입니다.class Node: def __init__(self, value=0, left=None, right = None): self.value=value self.left= left self.right = right def LCA(root,p,q): if root is None: return None left = LCA(root.left,p,q) right = LCA(root.right,p,q) if root.value == p or root.value ==q: return root elif left and right: return root return left or right root=[3,5,1,6,2,0,8,None,None,7,4] root = Node(value = 3) root.left = Node(value = 5) root.right = Node(value = 1) root.left.left = Node(value = 6) root.left.right = Node(value = 2) root.right.left = Node(value = 0) root.right.right = Node(value = 8) root.left.right.left = Node(value = 7) root.left.right.right = Node(value = 4) root= LCA(root,5,6) print(root.value) if root.value == p or root.value ==q: return root저는 여기서 root == p 를 하게 되면 아래 오류가 발생합니다.AttributeError: 'NoneType' object has no attribute 'value' 답변주시면 정말 감사하겠습니다.
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
정적 컨텐츠 서빙 흐름 질문드립니다
안녕하세요, 정적 컨텐츠 서빙 흐름에 관해 질문드립니다.교재의 위 이미지 및 강의 내용에 따르면,localhost:8080/hello-static.html 로 접속 시, 먼저 hello-static 관련 컨트롤러를 우선적으로 찾아보고, 없을 경우 static/hello-static.html 을 찾아보는 순서로 설명을 해주셨습니다.정말 그런가 하여 hello-static에 매핑되는 컨트롤러를 다음과 같이 추가(+resources/templates/hello-static-template.html 추가)해보았는데, 여전히 정적 컨텐츠인 src/main/resources/static/hello-static.html 이 서빙됩니다.package hello.hellospring; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @Controller public class HelloController { @GetMapping("/hello-static") String helloStatic() { return "hello-static-template"; } }따라서, 흐름도 이미지에 있는 것처럼 확장자(.html)까지 아예 명시하면, 컨트롤러를 거치지 않는 것이 아닌가 생각되는데, 제가 잘못 구현한 부분이 있거나 이해를 잘못 한 부분이 있을까요?감사합니다.관련 강의 및 교재강의 : '섹션 2. 스프링 웹 개발 기초' - 정적 컨텐츠교재 : 14p 정적 컨텐츠 서빙 흐름도 이미지
-
해결됨10주완성 C++ 코딩테스트 | 알고리즘 코딩테스트
2852번 문제 이해가 안돼요.
안녕하세요 선생님.NBA농구 문제를 푸는데 문제 이해를 잘못 한 것 같아요.1팀, 2팀이 각각 이기고 있는 시간을 출력하는 문제인데요. 아래 예제로 예를 들면, 1팀이 이기고 있는 시간은 01:10 ~ 45:30 으로 44분20초가 되어야 하는 것 같은데, 왜 45:30인지 모르겠어요.예제 입력 2번에서는 01:10 ~ 21:10으로 1팀이 20분 이기고 있는 것이 맞는데 예제 3번에서는 왜 다른지 이해가 안돼요.
-
미해결[NarP Series] MVC 프레임워크는 내 손에 [나프2탄]
강의 17:23초
MemberDAO dao = new MemberDAO();String user_name = dao.memberLogin(vo);if(user_name != null && ! "".equals(user_name)){ //성공}else { // 실패 } 여기서 ! "".equals(user_name)는 왜하는건가요?
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
순수 jdbc 회원 목록 IllegalStateException 라이브러리 에러
ERROR 7708 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.IllegalStateException: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection] with root cause JdbcMemberRepository 클래스에서 pdf파일을 복붙한 후 전체 Run 누르고 localhost에서 회원 목록을 조회했더니 웹에서 실행이 안됩니다.라이브러리가 안 맞아서 에러가 난 것 같은데 구글링에서 찾아봐도 없어서 질문 올립니다.라이브러리만 따로 수정할 수 있나요?아니면 저 클래스만 다시 작성해야 될까요?앞으로도 스프링부트 쓰다 보면 에러가 계속 날 수도 있는데 spring 홈페이지에서 관련 문서를 찾아보면 될까요?어떻게 하면 될까요?
-
미해결처음 만난 리액트(React)
목소리 너무 좋습니다
마음이 안정 됩니다 너무 설명도 잘하고 쉽고 유료강의보다 5천억만배 최강으로 최고 입니다
-
해결됨CS 지식의 정석 | 디자인패턴 네트워크 운영체제 데이터베이스 자료구조
128p UDP+IPv6 로 사용할 때 체크섬필드 사용 설정해야 하는 이유?
UDP 사용할 때 체크섬필드 선택사항이지만 UDP+IPv6 로 사용할 때 체크섬필드 사용 설정해야 하는 이유는IPv4는 체크섬이 있지만 IPv6에는 없기 때문인가요? 'UDP 사용할 때'에서 이 경우는 IPv4와 사용할 때를 가리키는 것인지요?
-
해결됨CS 지식의 정석 | 디자인패턴 네트워크 운영체제 데이터베이스 자료구조
상위 프로토콜 체크섬 존재와 IPv6의 CRC제외의 연관성
헤더 효율화를 위해 CRC(순환 중복검사)를 제외합니다. 다만 상위 프로토콜(TCP, UDP)에서 체크섬이 있기 때문에 이를 제거할 수 있습니다.이 두 문장의 연결이 이해가 안됩니다. 단순히 접속사를 잘못 쓰신건지요?원래 의도하신 건 '상위 프로토콜에 체크섬이 있기 때문에 IPv6에서 헤더효율화를 위한 CRC제외가 가능하다' 라는 의미인지요?
-
해결됨Flutter 초입문 왕초보편
코드 예제소스
중간에 따라하다가 실수로 뭐가 잘못된건지 따라한 작성내용이 다날라가서혹시 코드소스 있으면 올려주실수있나요?
-
미해결스프링 핵심 원리 - 기본편
스프링 빈 조회
스프링 빈을 왜 test 코드를짜서 검증을 해야하나요? 프레임워크가 자동적으로 컨테이너에 잘 등록했을 텐데 검증하는게 이해가 안가서요
-
미해결[개정판] 파이썬 머신러닝 완벽 가이드
Confusion Matrix and Type Errors
Confusion Matrix 의 FN 과 FP 는 혹시 Statistics 학문에서의 Type I Error 와 Type II Error 인가요?
-
해결됨스프링 MVC 2편 - 백엔드 웹 개발 활용 기술
쿠키와 세션의 차이는 무엇인가요??
쿠키는 클라이언트에 저장된다고하는데 그 이유를 모르겠습니다
-
미해결스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
결국 완강을 했습니다!
수강 신청은 몇 달 전에 했는데계속 듣다가 이해가 안가서 좀 쉬다가또 흐름이 끊기고 기억이 사라져 처음부터 다시듣기를 반복하다가 드디어 오늘 거진 3개월 만에완강을 했습니다!최소한의 이해로 따라온 강의지만 꽤 스프링에 대한이해도가 깊어진 것 같습니다ORM인 JPA를 배운 것이 특히 신기하게 집중되고흥미로웠습니다. 복잡한 sql코드를 없앨 수 있어서 그랬던것 같습니다, ㅎㅎ. 모든 로드맵을 구매하였으니 선생님만 믿고 스프링 강의를 무한 반복하여 많은 것을 얻어 가겠습니다!! 감사합니다.
-
미해결프로그래밍 시작하기 : 파이썬 입문 (Inflearn Original)
vscode 질문
안녕하세요실행 관련해서 이게 될 때도 있고 안 될 때도 있는데 대부분 실행이 안 돼서 질문 남깁니다.ㅜ사진 보시다시피 def랑 print 색깔도 그냥 일반 언어 색깔처럼 처리되고 실행을 해도 자꾸 디버깅 확장 관련 오류 메세지만 떠서요어떤 부분이 잘못 되었는지 알 수 있을까요??
-
해결됨스프링 핵심 원리 - 기본편
IllegalStateException과UnsatisfiedDependencyException이 뜨는데 어디서 잘못됬을까요?
학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.1. 강의 내용과 관련된 질문을 남겨주세요.2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.(자주 하는 질문 링크: https://bit.ly/3fX6ygx)3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.=========================================[질문 템플릿]1. 강의 내용과 관련된 질문인가요? (예/아니오)2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)[질문 내용] Test파일 실행을 시켜보면 오류가 발생하는데요 도대체 어떤 이유인지 잘 모르겠습니다. 최대한 제가 스스로 해결해보려다가 안되서 질문을 드려봅니다. 다만 걸리는 부분이 있다면 lombok을 설치할 때 build.gradle이 아니라 bulid.gradle.kts라고 되어 있어서 build.gradle로 파일을 변경 시켜주었습니다. 어떻게 해결할 방법이 있나요? org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'member' defined in file [/Users/leedongyoung/스프링 연습/core/out/production/classes/hello/core/member/Member.class]: Unsatisfied dependency expressed through constructor parameter 0: No qualifying bean of type 'java.lang.Long' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1352) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1189) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:917) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:93) at hello.core.scan.AutoAppConfigTest.basicScan(AutoAppConfigTest.java:18) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86) at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103) at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92) at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.Long' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1824) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1383) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ... 84 more.----------------------------------------- java.lang.IllegalStateException: Failed to load ApplicationContext for [MergedContextConfiguration@387bf2d9 testClass = hello.core.CoreApplicationTests, locations = [], classes = [hello.core.CoreApplication], contextInitializerClasses = [], activeProfiles = [], propertySourceLocations = [], propertySourceProperties = ["org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true"], contextCustomizers = [org.springframework.boot.test.autoconfigure.actuate.observability.ObservabilityContextCustomizerFactory$DisableObservabilityContextCustomizer@9da1, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@70fab835, org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@32057e6, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@53499d85, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@25f9407e, org.springframework.boot.test.context.SpringBootTestAnnotation@c1aac726], contextLoader = org.springframework.boot.test.context.SpringBootContextLoader, parent = null] at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:142) at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:127) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:141) at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:97) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:241) at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:138) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$10(ClassBasedTestDescriptor.java:377) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:382) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$11(ClassBasedTestDescriptor.java:377) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:310) at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:376) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$6(ClassBasedTestDescriptor.java:289) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:288) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$4(ClassBasedTestDescriptor.java:278) at java.base/java.util.Optional.orElseGet(Optional.java:364) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$5(ClassBasedTestDescriptor.java:277) at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:105) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:104) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:68) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$2(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'member' defined in file [/Users/leedongyoung/스프링 연습/core/out/production/classes/hello/core/member/Member.class]: Unsatisfied dependency expressed through constructor parameter 0: No qualifying bean of type 'java.lang.Long' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:798) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:245) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1352) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1189) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:973) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:917) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) at org.springframework.boot.test.context.SpringBootContextLoader.lambda$loadContext$3(SpringBootContextLoader.java:137) at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58) at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46) at org.springframework.boot.SpringApplication.withHook(SpringApplication.java:1388) at org.springframework.boot.test.context.SpringBootContextLoader$ContextLoaderHook.run(SpringBootContextLoader.java:545) at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:137) at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:108) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:184) at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:118) ... 72 moreCaused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'java.lang.Long' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1824) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1383) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:885) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:789) ... 96 more
-
해결됨실전! Querydsl
nullSafeBuilder메서드를 통해 null처리의 한계
개인 프로젝트를 진행하던중 where절의 조건들을 체이닝하는 과정에서 아래코드를 보면 경우 제일 앞에있는 nameLike()메서드가 null일 경우 에러가 발생하였습니다. and 조건일 경우 , 로 체이닝하면 되었지만 or조건들은 무조건 or()을 통해 연결을 해주어야했습니다.query.selectFrom(member) .where(nameLike("infren").or(nameEq("김영한강사님"))) .fetch();BooleanBuilder를 통해 조건을 처리해도되지만인프런 게시판을 통해알게된 nullSafeBuilder메서드를 만들어서 null처리를 하는 방법을 알게되었습니다. 하지만 몇가지 한계점들을 발견하였습니다.eq문에 null이 들어갈 경우에는 정상적으로 작동하였으나like절, 또는 in절에는 상황에 따라서 null을 넣을 경우 like,in문 자체가 파라미터로 null을 받지 못함으로 인해서 eq와는 다르게 작동하는 것을 발견하였습니다.몇 가지 경우의 테스트를 진행해보았습니다.eq절에 null을 넣을경우like절에 null을 넣을 경우 -> NullPointerExceptionin절에 String타입의 null을 넣을 경우in절에 String[] 타입의 null을 넣을 경우in절에 List<> 타입의 null을 넣을 경우 -> NullPointerExceptionin절에 객체(Team) null을 넣을 경우@Test void eq에Null을넣을때(){ String name = null; List<Member> findMember = query.selectFrom(member) .where(nullSafeBuilder(()-> member.username.eq(name))) .fetch(); assertEquals(findMember.size(),4); } @Test() void like절에_Null을_넣을때(){ String name = null; assertThrows(NullPointerException.class, () -> { List<Member> findMember = query.selectFrom(member) .where(nullSafeBuilder(()-> member.username.like(name))) .fetch(); }); } @Test void in절에_String타입의_Null을_넣을때(){ String name = null; List<Member> findMember = query.selectFrom(member) .where(nullSafeBuilder(()-> member.username.in(name))) .fetch(); assertEquals(findMember.size(),4); } @Test void in절에_String배열타입의_Null을_넣을때(){ String name = null; List<Member> findMember = query.selectFrom(member) .where(nullSafeBuilder(()-> member.username.in(name))) .fetch(); assertEquals(findMember.size(),4); } @Test void in절에_List에_Null을_넣을때(){ List<Team> team = null; assertThrows(NullPointerException.class, () -> { List<Member> findMember = query.selectFrom(member) .where(nullSafeBuilder(()-> member.team.in(team))) .fetch(); }); } @Test void in절에_Team타입의_Null을_넣을때(){ Team team = null; List<Member> findMember = query.selectFrom(member) .where(nullSafeBuilder(()-> member.team.in(team))) .fetch(); assertEquals(findMember.size(),4); } public static BooleanBuilder nullSafeBuilder(Supplier<BooleanExpression> f) { try { return new BooleanBuilder(f.get()); } catch (IllegalArgumentException e) { return new BooleanBuilder(); } }where절안에서 사용하는 함수(like, in...등등)에 따라 파라미터 자체에 null을 받지 못함으로인해 nullSafeBuilder를 통해 해결할 수 없는 경우도 있는것 같습니다.이러한 경우에는 강사님께서 알려주셨던 아래와 같은 방법으로 메서드를 통해 파라미터의 null처리를 해주고private BooleanExpression nameLike(String name){ return name != null ? member.username.like(name) : null; }체이닝할 때는 and조건이면 , 를 사용하고, or조건으로 체이닝을 해야할 경우에는 BooleanBuilder객체에 체이닝하는 방식으로 구현을 해야할 것 같습니다.아래는 프로젝트에 적용했던 동적쿼리문 입니다. 앞서 말했듯이 and조건은 ,로 연결하고 or조건들은 Booleanbuilder객체에 체이닝을 하였습니다.//페이징 처리를 하지않은 동적쿼리문 -> 테스트에서 사용 public List<Article> searchBooleanBuilder(ArticleSearchCond cond) { BooleanBuilder builder = new BooleanBuilder(); builder.or(contentLike(cond.getContent()))//글 내용 keyword검색 .or(nickNameLike(cond.getWriter()))//작성자(닉네임) keyword검색 .or(nameLike(cond.getWriter()))//작성자(이름) keyword검색 .or(tagArticleIn(cond.getArticlesByTagValue()))//태그 keyword검색 .or(restaurantNameLike(cond.getRestaurantName()));//음식점명 keyword검색 return query.selectFrom(article) .where( followMembersIn(cond.getFollowMembers()),//팔로우한 유저로 검색 sidoEq(cond.getSido()),//시도로 검색 sigoonEq(cond.getSigoon()),//시군으로 검색 dongEq(cond.getDong()),//동으로 검색 latitudeBetween(cond.getLatitude()),//위도로 검색 longitudeBetween(cond.getLongitude()),//경도로 검색 categoryEq(cond.getCategory()),//음식점 카테고리로 검색 likeArticleIn(cond.getLikeArticles()),//좋아요누른 게시판 검색 builder//keyword조건 검색 ) .orderBy(article.id.desc())//아이디가 높은 것(최신순)으로 내림차순 .limit(20) .fetch(); }아래는 nullSafeBuilder의 한계를 모른 상태로 구현하였던 에러가 발생하는 코드입니다. radioBtnSearchCond(and조건들), keywordSearchCond(or조건으로 연결)안에 nullsafeBuilder로 null처리한 메서드들이 있습니다. public List<Article> searchByNullSafer(ArticleSearchCond cond) { return query.selectFrom(article) .where( radioBtnSearchCond(cond)//라디로 버튼 검색 조건들 .and(keywordSearchCond(cond))//keyword로 검색 조건들 ) .orderBy(article.id.desc())//아이디가 높은 것(최신순)으로 내림차순 .fetch(); }혹시 nullSafeBuilder를 구현 좋은 방법이 있던가, 다른 좋은 방법을 아시는 분이 있으면 알려주시면 감사하겠습니다.
-
해결됨스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술
join 메소드는 리턴값이 있는데 왜 그냥 호출해도 오류가 안나나요?
안녕하세요! 제목처럼 join 메소드는 회원가입시키고 아이디를 리턴해주는데 왜 테스트케이스는 리턴값을 따로 안받아줘도 오류가 나지않나요?memberService.join(member);-> 따로 Long saveId = memberService.join(member);이렇게 안해줘도 오류가 안나서 궁금합니다!