我有一个spring应用程序,其web.xml如下所示:
<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'
我哪里错了?
答案 0 :(得分:1)
可能出现的问题很少:
请参阅以下项目,检查您是否正确配置了应用程序:Spring Security for REST Example Project