NutzCN Logo
问答 nutz 使用swagger的时候遇到的问题
发布于 2507天前 作者 zjhk 2583 次浏览 复制 上一个帖子 下一个帖子
标签:

1.swagger 加载不了@At("/****") 当方法名与@At() 里面映射的路径不一致的时候,swagger检索的是方法名,不是@At()注解里面的路径
2.当第一次访问http://localhost:8081/swagger/ 的时候后台会报 java.lang.ClassNotFoundException:错误.

2018-01-04 10:31:52,487 [http-nio-8081-exec-2] ERROR io.swagger.util.ReflectionUtils - Failed to resolve '' into class
java.lang.ClassNotFoundException: 
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
	at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
	at io.swagger.util.ReflectionUtils.loadClassByName(ReflectionUtils.java:49)
	at io.swagger.util.ReflectionUtils.typeFromString(ReflectionUtils.java:31)
	at io.swagger.servlet.extensions.ServletReaderExtension.readImplicitParam(ServletReaderExtension.java:419)
	at io.swagger.servlet.extensions.ServletReaderExtension.applyImplicitParameters(ServletReaderExtension.java:398)
	at io.swagger.servlet.Reader.read(Reader.java:100)
	at io.swagger.servlet.Reader.read(Reader.java:58)
	at com.hefupb.hegui.modules.SwaggerModule.init(SwaggerModule.java:55)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.nutz.ioc.trigger.MethodEventTrigger.trigger(MethodEventTrigger.java:18)
	at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:72)
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:139)
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:216)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:110)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1457)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
2 回复

因为没有做桥接或插件. 用原生Swagger的注解来标注就好了, 不会与@At产生关联性.

至于"Failed to resolve '' into class" , 应该是你的swagger注解有地方写错了

添加回复
请先登陆
回到顶部