我正在使用与Jetty/Jersey的Swagger的2.1.16,我得到这个异常。我曾尝试在SwaggerConfiguration上使用readAllResources(false)关闭类路径扫描,因为我不想要这个功能,但它没有帮助。我可能做错了什么。但是什么?
谢谢,乔纳森。
java.lang.NoClassDefFoundError: io/github/classgraph/ClassGraph
at io.swagger.v3.jaxrs2@2.1.6/io.swagger.v3.jaxrs2.integration.JaxrsAnnotationScanner.classes(JaxrsAnnotationScanner.java:60)
at io.swagger.v3.jaxrs2@2.1.6/io.swagger.v3.jaxrs2.integration.JaxrsApplicationAndAnnotationScanner.classes(JaxrsApplicationAndAnnotationScanner.java:10)
at io.swagger.v3.oas.integration@2.1.6/io.swagger.v3.oas.integration.GenericOpenApiContext.read(GenericOpenApiContext.java:555)
at io.swagger.v3.jaxrs2@2.1.6/io.swagger.v3.jaxrs2.integration.OpenApiServlet.doGet(OpenApiServlet.java:55)
at javax.servlet.api@3.1.0/javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.api@3.1.0/javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet@9.4.36.v20210114/org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:791)
at org.eclipse.jetty.servlet@9.4.36.v20210114/org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1626)
at wicket.core@9.2.0/org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:293)
at wicket.core@9.2.0/org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:208)
at wicket.core@9.2.0/org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:307)
at org.eclipse.jetty.servlet@9.4.36.v20210114/org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
at org.eclipse.jetty.servlet@9.4.36.v20210114/org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
at org.eclipse.jetty.servlet@9.4.36.v20210114/org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1435)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at org.eclipse.jetty.servlet@9.4.36.v20210114/org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1350)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.Server.handle(Server.java:516)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)
at org.eclipse.jetty.server@9.4.36.v20210114/org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
at org.eclipse.jetty.io@9.4.36.v20210114/org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io@9.4.36.v20210114/org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
at org.eclipse.jetty.io@9.4.36.v20210114/org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at org.eclipse.jetty.util@9.4.36.v20210114/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
at org.eclipse.jetty.util@9.4.36.v20210114/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
at org.eclipse.jetty.util@9.4.36.v20210114/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
at org.eclipse.jetty.util@9.4.36.v20210114/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135)
at org.eclipse.jetty.util@9.4.36.v20210114/org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:773)
at org.eclipse.jetty.util@9.4.36.v20210114/org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:905)
at java.base/java.lang.Thread.run(Thread.java:835)
Swagger包含一个过时版本的io.github.classgraph,导致java.lang.NoClassDefFoundError。我能够排除由Swagger包含的classgraph版本,并包含最新的版本。在那之后,我在module-info.java中丢失了require语句,现在它可以工作了。这个问题已经在master of Swagger repo中修复了,但还没有在任何版本中修复。
我在maven依赖中遇到了一个问题:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.4</version>
</dependency>
唯一对我有用的是降级到1.6.3,它摆脱了Cannot resolve io.github.classgraph:classgraph:4.8.13
8的错误。