0
我有一個Spring應用程序,其web.xml文件看起來像如下:swagger2不與彈簧安置工作
<servlet>
<servlet-name>app</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/app-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>app</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>app</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
裏面我app-servlet.xml
我有如下的配置項:
<context:component-scan base-package="com.rest.apidoc" />
我有我的SwaggerConfig
裏面的com.rest.apidoc
目錄
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
現在當我嘗試運行應用程序http://domain:port/app/service/api-docs
,我得到我的控制檯上的錯誤No mapping found for HTTP request with URI [/app/service/api-docs] in DispatcherServlet with name 'app'
我在哪裏出錯了?