인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

남종진님의 프로필 이미지

작성한 질문수

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

JPA

테스트 오류

작성

·

495

0

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요.

1. 강의 내용과 관련된 질문을 남겨주세요.
2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요.
(자주 하는 질문 링크: https://bit.ly/3fX6ygx)
3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요.
(질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG)

질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.
=========================================
[질문 템플릿]
1. 강의 내용과 관련된 질문인가요? (예/아니오)
2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)
3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)

[질문 내용]
여기에 질문 내용을 남겨주세요
 
JPA 테스트 실행시 나타나는 오류입니다..... 원인을 잘 모르겠습니다
H2 켜놓은 상태입니다

 Failed to load ApplicationContext java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132) at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124) at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190) at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132) at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248) at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:138) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambdainvokeTestInstancePostProcessorsinvokeTestInstancePostProcessors8(ClassBasedTestDescriptor.java:363) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:368) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambdainvokeTestInstancePostProcessorsinvokeTestInstancePostProcessors9(ClassBasedTestDescriptor.java:363) at java.base/java.util.stream.ReferencePipeline331.accept(ReferencePipeline.java:195) at java.base/java.util.stream.ReferencePipeline221.accept(ReferencePipeline.java:177) at java.base/java.util.ArrayListArrayListSpliterator.forEachRemaining(ArrayList.java:1655)atjava.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)atjava.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)atjava.base/java.util.stream.StreamSpliteratorsArrayListSpliterator.forEachRemaining(ArrayList.java:1655) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) at java.base/java.util.stream.StreamSpliteratorsWrappingSpliterator.forEachRemaining(StreamSpliterators.java:312) at java.base/java.util.stream.StreamsConcatSpliterator.forEachRemaining(Streams.java:735)atjava.base/java.util.stream.StreamsConcatSpliterator.forEachRemaining(Streams.java:735) at java.base/java.util.stream.StreamsConcatSpliterator.forEachRemaining(Streams.java:734) at java.base/java.util.stream.ReferencePipelineHead.forEach(ReferencePipeline.java:658)atorg.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:362)atorg.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambdaHead.forEach(ReferencePipeline.java:658) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:362) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambdainstantiateAndPostProcessTestInstance6(ClassBasedTestDescriptor.java:283)atorg.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)atorg.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:282)atorg.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda6(ClassBasedTestDescriptor.java:283) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:282) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambdatestInstancesProvider4(ClassBasedTestDescriptor.java:272)atjava.base/java.util.Optional.orElseGet(Optional.java:369)atorg.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda4(ClassBasedTestDescriptor.java:272) at java.base/java.util.Optional.orElseGet(Optional.java:369) at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambdatestInstancesProvider5(ClassBasedTestDescriptor.java:271)atorg.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31)atorg.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda5(ClassBasedTestDescriptor.java:271) at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambdaprepare0(TestMethodTestDescriptor.java:102)atorg.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)atorg.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:101)atorg.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:66)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.lambda0(TestMethodTestDescriptor.java:102) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:101) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:66) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambdaprepare2(NodeTestTask.java:123)atorg.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:123)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:90)atjava.base/java.util.ArrayList.forEach(ArrayList.java:1541)atorg.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.lambda2(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:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambdaexecuteRecursively6(NodeTestTask.java:155)atorg.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.lambda6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambdaexecuteRecursively8(NodeTestTask.java:141)atorg.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.lambda8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambdaexecuteRecursively9(NodeTestTask.java:139)atorg.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)atjava.base/java.util.ArrayList.forEach(ArrayList.java:1541)atorg.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.lambda9(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:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambdaexecuteRecursively6(NodeTestTask.java:155)atorg.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.lambda6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambdaexecuteRecursively8(NodeTestTask.java:141)atorg.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.lambda8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambdaexecuteRecursively9(NodeTestTask.java:139)atorg.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)atorg.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)atorg.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)atorg.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)atorg.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)atorg.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)atorg.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)atorg.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda9(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:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambdaexecute0(EngineExecutionOrchestrator.java:54)atorg.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)atorg.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)atorg.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)atorg.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)atorg.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessorCollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessorCollectAllTestClassesExecutor.accessCollectAllTestClassesExecutor.access000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapterDispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)atcom.sun.proxy.DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at com.sun.proxy.Proxy2.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193) at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74) Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'memberController' defined in file [C:\study\hello-spring\build\classes\java\main\hello\hellospring\controller\MemberController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'memberService' defined in class path resource [hello/hellospring/SpringConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [hello.hellospring.service.MemberService]: Factory method 'memberService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'memberRepository' defined in class path resource [hello/hellospring/SpringConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [hello.hellospring.repository.MemberRepository]: Factory method 'memberRepository' threw exception; nested exception is java.lang.ClassCastException: class com.sun.proxy.$Proxy93 cannot be cast to class javax.sql.DataSource (com.sun.proxy.Proxy93isinunnamedmoduleofloaderapp;javax.sql.DataSourceisinmodulejava.sqlofloaderplatform)atapp//org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800)atapp//org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)atapp//org.springframework.beans.factory.support.AbstractBeanFactory.lambdaProxy93 is in unnamed module of loader 'app'; javax.sql.DataSource is in module java.sql of loader 'platform') at app//org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) at app//org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at app//org.springframework.beans.factory.support.AbstractBeanFactory.lambdadoGetBean0(AbstractBeanFactory.java:335)atapp//org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)atapp//org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)atapp//org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)atapp//org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)atapp//org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)atapp//org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)atapp//org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)atapp//org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)atapp//org.springframework.boot.SpringApplication.run(SpringApplication.java:308)atapp//org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:132)atapp//org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)atapp//org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)...85moreCausedby:org.springframework.beans.factory.BeanCreationException:ErrorcreatingbeanwithnamememberServicedefinedinclasspathresource[hello/hellospring/SpringConfig.class]:Beaninstantiationviafactorymethodfailed;nestedexceptionisorg.springframework.beans.BeanInstantiationException:Failedtoinstantiate[hello.hellospring.service.MemberService]:FactorymethodmemberServicethrewexception;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:ErrorcreatingbeanwithnamememberRepositorydefinedinclasspathresource[hello/hellospring/SpringConfig.class]:Beaninstantiationviafactorymethodfailed;nestedexceptionisorg.springframework.beans.BeanInstantiationException:Failedtoinstantiate[hello.hellospring.repository.MemberRepository]:FactorymethodmemberRepositorythrewexception;nestedexceptionisjava.lang.ClassCastException:classcom.sun.proxy.0(AbstractBeanFactory.java:335) at app//org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at app//org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at app//org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at app//org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) at app//org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) at app//org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) at app//org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) at app//org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) at app//org.springframework.boot.SpringApplication.run(SpringApplication.java:308) at app//org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:132) at app//org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) at app//org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ... 85 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'memberService' defined in class path resource [hello/hellospring/SpringConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [hello.hellospring.service.MemberService]: Factory method 'memberService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'memberRepository' defined in class path resource [hello/hellospring/SpringConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [hello.hellospring.repository.MemberRepository]: Factory method 'memberRepository' threw exception; nested exception is java.lang.ClassCastException: class com.sun.proxy.Proxy93 cannot be cast to class javax.sql.DataSource (com.sun.proxy.Proxy93isinunnamedmoduleofloaderapp;javax.sql.DataSourceisinmodulejava.sqlofloaderplatform)atapp//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)atapp//org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)atapp//org.springframework.beans.factory.support.AbstractBeanFactory.lambdaProxy93 is in unnamed module of loader 'app'; javax.sql.DataSource is in module java.sql of loader 'platform') at app//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) at app//org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at app//org.springframework.beans.factory.support.AbstractBeanFactory.lambdadoGetBean0(AbstractBeanFactory.java:335)atapp//org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)atapp//org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)atapp//org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)atapp//org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)atapp//org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391)atapp//org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)atapp//org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887)atapp//org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791)...103moreCausedby:org.springframework.beans.BeanInstantiationException:Failedtoinstantiate[hello.hellospring.service.MemberService]:FactorymethodmemberServicethrewexception;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:ErrorcreatingbeanwithnamememberRepositorydefinedinclasspathresource[hello/hellospring/SpringConfig.class]:Beaninstantiationviafactorymethodfailed;nestedexceptionisorg.springframework.beans.BeanInstantiationException:Failedtoinstantiate[hello.hellospring.repository.MemberRepository]:FactorymethodmemberRepositorythrewexception;nestedexceptionisjava.lang.ClassCastException:classcom.sun.proxy.0(AbstractBeanFactory.java:335) at app//org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at app//org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at app//org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at app//org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) at app//org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1391) at app//org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) at app//org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) at app//org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ... 103 more Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [hello.hellospring.service.MemberService]: Factory method 'memberService' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'memberRepository' defined in class path resource [hello/hellospring/SpringConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [hello.hellospring.repository.MemberRepository]: Factory method 'memberRepository' threw exception; nested exception is java.lang.ClassCastException: class com.sun.proxy.Proxy93 cannot be cast to class javax.sql.DataSource (com.sun.proxy.Proxy93isinunnamedmoduleofloaderapp;javax.sql.DataSourceisinmodulejava.sqlofloaderplatform)atapp//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)atapp//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)...117moreCausedby:org.springframework.beans.factory.BeanCreationException:ErrorcreatingbeanwithnamememberRepositorydefinedinclasspathresource[hello/hellospring/SpringConfig.class]:Beaninstantiationviafactorymethodfailed;nestedexceptionisorg.springframework.beans.BeanInstantiationException:Failedtoinstantiate[hello.hellospring.repository.MemberRepository]:FactorymethodmemberRepositorythrewexception;nestedexceptionisjava.lang.ClassCastException:classcom.sun.proxy.Proxy93 is in unnamed module of loader 'app'; javax.sql.DataSource is in module java.sql of loader 'platform') at app//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) at app//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ... 117 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'memberRepository' defined in class path resource [hello/hellospring/SpringConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [hello.hellospring.repository.MemberRepository]: Factory method 'memberRepository' threw exception; nested exception is java.lang.ClassCastException: class com.sun.proxy.Proxy93 cannot be cast to class javax.sql.DataSource (com.sun.proxy.Proxy93isinunnamedmoduleofloaderapp;javax.sql.DataSourceisinmodulejava.sqlofloaderplatform)atapp//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658)atapp//org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)atapp//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)atapp//org.springframework.beans.factory.support.AbstractBeanFactory.lambdaProxy93 is in unnamed module of loader 'app'; javax.sql.DataSource is in module java.sql of loader 'platform') at app//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) at app//org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:486) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) at app//org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) at app//org.springframework.beans.factory.support.AbstractBeanFactory.lambdadoGetBean0(AbstractBeanFactory.java:335)atapp//org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)atapp//org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)atapp//org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)atapp//org.springframework.context.annotation.ConfigurationClassEnhancer0(AbstractBeanFactory.java:335) at app//org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) at app//org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) at app//org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) at app//org.springframework.context.annotation.ConfigurationClassEnhancerBeanMethodInterceptor.resolveBeanReference(ConfigurationClassEnhancer.java:362) at app//org.springframework.context.annotation.ConfigurationClassEnhancerBeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:334)atapp//hello.hellospring.SpringConfigBeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:334) at app//hello.hellospring.SpringConfigEnhancerBySpringCGLIBEnhancerBySpringCGLIB5a22a17.memberRepository(<generated>)atapp//hello.hellospring.SpringConfig.memberService(SpringConfig.java:27)atapp//hello.hellospring.SpringConfig5a22a17.memberRepository(<generated>) at app//hello.hellospring.SpringConfig.memberService(SpringConfig.java:27) at app//hello.hellospring.SpringConfigEnhancerBySpringCGLIBEnhancerBySpringCGLIB5a22a17.CGLIB5a22a17.CGLIBmemberService0(<generated>)atapp//hello.hellospring.SpringConfig0(<generated>) at app//hello.hellospring.SpringConfigEnhancerBySpringCGLIBEnhancerBySpringCGLIB5a22a175a22a17FastClassBySpringCGLIBFastClassBySpringCGLIBc576d6fc.invoke(<generated>)atapp//org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)atapp//org.springframework.context.annotation.ConfigurationClassEnhancerc576d6fc.invoke(<generated>) at app//org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) at app//org.springframework.context.annotation.ConfigurationClassEnhancerBeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) at app//hello.hellospring.SpringConfigEnhancerBySpringCGLIB5a22a17.memberService(<generated>) at java.base@11.0.15/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base@11.0.15/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base@11.0.15/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base@11.0.15/java.lang.reflect.Method.invoke(Method.java:566) at app//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ... 118 more Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [hello.hellospring.repository.MemberRepository]: Factory method 'memberRepository' threw exception; nested exception is java.lang.ClassCastException: class com.sun.proxy.Proxy93cannotbecasttoclassjavax.sql.DataSource(com.sun.proxy.Proxy93 cannot be cast to class javax.sql.DataSource (com.sun.proxy.Proxy93 is in unnamed module of loader 'app'; javax.sql.DataSource is in module java.sql of loader 'platform') at app//org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) at app//org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ... 141 more Caused by: java.lang.ClassCastException: class com.sun.proxy.Proxy93cannotbecasttoclassjavax.sql.DataSource(com.sun.proxy.Proxy93 cannot be cast to class javax.sql.DataSource (com.sun.proxy.Proxy93 is in unnamed module of loader 'app'; javax.sql.DataSource is in module java.sql of loader 'platform') at hello.hellospring.repository.JdbcMemberRepository.<init>(JdbcMemberRepository.java:17) at hello.hellospring.SpringConfig.memberRepository(SpringConfig.java:34) at hello.hellospring.SpringConfigEnhancerBySpringCGLIB5a22a17.CGLIBmemberRepositorymemberRepository1(<generated>) at hello.hellospring.SpringConfigEnhancerBySpringCGLIB5a22a17FastClassBySpringCGLIBc576d6fc.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) at org.springframework.context.annotation.ConfigurationClassEnhancerBeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331)athello.hellospring.SpringConfigBeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) at hello.hellospring.SpringConfigEnhancerBySpringCGLIBEnhancerBySpringCGLIB$5a22a17.memberRepository(<generated>) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ... 142 more

.

답변 1

0

David님의 프로필 이미지

안녕하세요. 남종진


전체 프로젝트를 압축해서 구글 드라이브로 공유해서 링크를 남겨주세요.
구글 드라이브 업로드 방법은 다음을 참고해주세요.

https://bit.ly/3fX6ygx

주의: 업로드시 권한 문제 꼭 확인해주세요

추가로 다음 내용도 코멘트 부탁드립니다.

1. 실행 방법을 알려주세요.
2. 어떻게 문제를 확인할 수 있는지 자세한 설명을 남겨주세요.

감사합니다

남종진님의 프로필 이미지
남종진
질문자

https://drive.google.com/file/d/1b3kUfbEr9Ay7OKQKTrZzAppbNu38WgEA/view?usp=sharing 입니다

 

MemberServiceIntegrationTest 실행 시 오류가 나타납니다

David님의 프로필 이미지

질문 올리셨을 때랑 코드가 달라진 것 같은데 맞나요?

 

올려주신 코드를 기준으로 아래 코드를 추가/변경한 다음 실행하니깐 정상적으로 실행됩니다.

spring.jpa.database=h2

spring.jpa.hibernate.ddl-auto = create

남종진님의 프로필 이미지
남종진
질문자

코드 입력 했는데 똑같이 오류가 나타납니다....

David님의 프로필 이미지

이 부분은 질문자님께서 Config 파일에도 TimeTraceAop 빈을 생성하시고, TimeTraceAop에서 @Component로 빈을 생성하셔서 충돌난 상황입니다.

둘 중 하나를 제거해주세요.

남종진님의 프로필 이미지
남종진
질문자

하나를 제거하니까 정상적으로 작동합니다. 감사합니다!