{"id":308,"date":"2022-09-06T18:03:09","date_gmt":"2022-09-06T10:03:09","guid":{"rendered":"https:\/\/deeperxh.com\/?p=308"},"modified":"2022-09-06T18:03:09","modified_gmt":"2022-09-06T10:03:09","slug":"%e8%ae%b0%e5%bd%95%e8%a7%a3%e5%86%b3springboot%e5%8d%95%e5%85%83%e6%b5%8b%e8%af%95%e9%81%87%e5%88%b0%e7%9a%84failed-to-load-applicationcontext%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/deeperxh.com\/?p=308","title":{"rendered":"\u8bb0\u5f55\u89e3\u51b3springboot\u5355\u5143\u6d4b\u8bd5\u9047\u5230\u7684Failed to load ApplicationContext\u95ee\u9898"},"content":{"rendered":"<p>\u57fa\u672c\u60c5\u51b5\uff1ajunit5+springboot test<\/p>\n<p>\u5355\u5143\u6d4b\u8bd5\u7a0b\u5e8f\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"\">@SpringBootTest(classes = {com.starter.run.ApplicationRunner.class})\npublic class Test1 {\n    @Test\n    public void test(){\n        System.out.println(\"test\");\n    }\n}\n\n<\/code><\/pre>\n<p>\u542f\u52a8@Test\u65f6\u5019\u62a5\u9519\uff1a<\/p>\n<pre><code class=\"\"><br \/>java.lang.IllegalStateException: Failed to load ApplicationContext\n\n    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)\n    at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:123)\n    at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)\n    at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)\n    at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)\n    at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:98)\n    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$5(ClassBasedTestDescriptor.java:341)\n    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:346)\n    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$6(ClassBasedTestDescriptor.java:341)\n    at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)\n    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)\n    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)\n    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)\n    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)\n    at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)\n    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:743)\n    at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:742)\n    at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)\n    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:340)\n    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:263)\n    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$2(ClassBasedTestDescriptor.java:256)\n    at java.util.Optional.orElseGet(Optional.java:267)\n    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$3(ClassBasedTestDescriptor.java:255)\n    at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:29)\n    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:108)\n    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)\n    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:107)\n    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:71)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:107)\n    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:107)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:75)\n    at java.util.ArrayList.forEach(ArrayList.java:1259)\n    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)\n    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)\n    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)\n    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)\n    at java.util.ArrayList.forEach(ArrayList.java:1259)\n    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)\n    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)\n    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)\n    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)\n    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)\n    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)\n    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)\n    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)\n    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)\n    at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)\n    at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)\n    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)\n    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)\n    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)\n    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)\n    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)\n    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)\nCaused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'procDemo': Unsatisfied dependency expressed through field 'processRpcService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'top.rdfa.bp.security.facade.api.ProcessRpcService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}\n    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660)\n    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)\n    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)\n    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1425)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)\n    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)\n    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)\n    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)\n    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)\n    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)\n    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)\n    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)\n    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)\n    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:755)\n    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)\n    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:402)\n    at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)\n    at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)\n    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)\n    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)\n    ... 63 more\nCaused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'top.rdfa.bp.security.facade.api.ProcessRpcService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}\n    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1717)\n    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1273)\n    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227)\n    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657)\n    ... 83 more\n\n\n<\/code><\/pre>\n<p>\u89e3\u51b3\u65b9\u6848<\/p>\n<pre><code class=\"\">@SpringBootTest(properties = \"spring.main.lazy-initialization=true\",\nclasses = {Abc.class})\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u672c\u60c5\u51b5\uff1ajunit5+springboot test \u5355\u5143\u6d4b\u8bd5\u7a0b\u5e8f\u5982\u4e0b\uff1a @SpringBootTest(c&hellip;<\/p>\n<p class=\"read-more\"><a class=\"readmore-btn\" href=\"https:\/\/deeperxh.com\/?p=308\">Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/deeperxh.com\/index.php?rest_route=\/wp\/v2\/posts\/308"}],"collection":[{"href":"https:\/\/deeperxh.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/deeperxh.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/deeperxh.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/deeperxh.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=308"}],"version-history":[{"count":2,"href":"https:\/\/deeperxh.com\/index.php?rest_route=\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":310,"href":"https:\/\/deeperxh.com\/index.php?rest_route=\/wp\/v2\/posts\/308\/revisions\/310"}],"wp:attachment":[{"href":"https:\/\/deeperxh.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/deeperxh.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/deeperxh.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}