我试图将swagger与我的api文档项目集成在一起。 但是,尽管提供了配置,restEasy无法映射到我的招摇基本网址。
我不确定我是否遗漏了部分内容。我几天来一直在研究这个问题,而且大多数时候我都在关注他们的文件Swagger Integration documentation。
我的web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.spring.SpringContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
我的spring-servlet.xml
<annotation-driven />
<beans:import resource="classpath:springmvc-resteasy.xml" />
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.sample.web.controller" />
<context:component-scan base-package="com.*.web">
<context:include-filter type="annotation" expression="javax.ws.rs.ext.Provider" />
</context:component-scan>
我的applicationContext.xml
<context:component-scan base-package="com.sample" />
<bean class="com.wordnik.swagger.jaxrs.listing.ApiListingResourceJSON" />
<bean class="com.wordnik.swagger.jaxrs.listing.ApiDeclarationProvider" />
<bean class="com.wordnik.swagger.jaxrs.listing.ResourceListingProvider" />
<bean id="beanConfig" class="com.wordnik.swagger.jaxrs.config.BeanConfig">
<property name="title" value="Swagger Sample App"/>
<property name="version" value="1.0.0" />
<property name="basePath" value="http://localhost:8100/rest"/>
<property name="resourcePackage" value="com.sample.web.controller"/>
<property name="scan" value="true"/>
</bean>
运行此项目然后检查此URL&#34; localhost:8100 / rest / api-docs /&#34;我收到以下堆栈跟踪
ERROR ResteasyHandlerMapping Resource Not Found: Could not find resource for relative : /rest/api-docs of full path: http://localhost:8100/rest/api-docs/ org.jboss.resteasy.spi.NotFoundException: Could no
找到相对的资源:/ rest / api-docs of full path:localhost:8100 / rest / api-docs / 在org.jboss.resteasy.core.registry.RootSegment.matchChildren(RootSegment.java:360) 在org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:374) 在org.jboss.resteasy.core.registry.RootSegment.matchRoot(RootSegment.java:367) 在org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:297) 在org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:173) 在org.jboss.resteasy.springmvc.ResteasyHandlerMapping.getInvoker(ResteasyHandlerMapping.java:99) 在org.jboss.resteasy.springmvc.ResteasyHandlerMapping.getHandler(ResteasyHandlerMapping.java:76) 在org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1104) 在org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:916) 在org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) 在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) 在org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:618) 在org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:725) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) 在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) 在org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) 在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) 在org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:673) 在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) 在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) 在org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085) at org.apache.coyote.AbstractProtocol $ AbstractConnectionHandler.process(AbstractProtocol.java:658) 在org.apache.coyote.http11.Http11NioProtocol $ Http11ConnectionHandler.process(Http11NioProtocol.java:222) 在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1556) 在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.run(NioEndpoint.java:1513) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run(Thread.java:745)