项目引入swagger,单元测试如下异常,有谁遇到过吗?
项目引入swagger,单元测试如下异常,有谁遇到过吗?2019-05-12 23:27:10.597WARN 11676 --- [ main] o.s.b.t.m.w.SpringBootMockServletContext : Couldn't determine real path of resource class path resource
java.io.FileNotFoundException: class path resource cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/C:/Users/chiangfai/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-swagger-ui/2.9.2/d542382a88ff3ea8d4032c28b2b0325797fada7d/springfox-swagger-ui-2.9.2.jar!/META-INF/resources/
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:217) ~
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:131) ~
at org.springframework.mock.web.MockServletContext.getRealPath(MockServletContext.java:457) ~
at org.beetl.ext.spring.BeetlGroupUtilConfiguration.setServletContext(BeetlGroupUtilConfiguration.java:161)
at org.springframework.web.context.support.ServletContextAwareProcessor.postProcessBeforeInitialization(ServletContextAwareProcessor.java:108)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1686)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759) ~
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:548) ~
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) ~
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) ~
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:127) ~
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) ~
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117) ~
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108) ~
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:246) ~
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227) ~
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289) ~
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) ~
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291) ~
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246) ~
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) ~
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) ~
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) ~
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) ~
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) ~
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) ~
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) ~
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) ~
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) ~
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) ~
at org.junit.runner.JUnitCore.run(JUnitCore.java:137) ~
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) ~
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) ~
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) ~
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) ~
绝对路径未找到 应该是jar包没有引入吧 感觉路径有问题 测试的部分不用引入swagger的包
页:
[1]