赞
踩
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>2.9.2</version>
- </dependency>
-
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger-ui</artifactId>
- <version>2.9.2</version>
- </dependency>
在SpringBoot项目引入Swagger2后,在浏览器地址里输入地址:http://ip:port/swagger-ui.html 报错:
控制台出现这样子的错误:swagger No mapping for GET /swagger-ui.html
解决办法:
- @Override
- public void addResourceHandlers(ResourceHandlerRegistry registry) {
- registry.addResourceHandler("doc.html")
- .addResourceLocations("classpath:/META-INF/resources/");
-
- registry.addResourceHandler("swagger-ui.html")
- .addResourceLocations("classpath:/META-INF/resources/");
- registry.addResourceHandler("/webjars/**")
- .addResourceLocations("classpath:/META-INF/resources/webjars/");
- }
访问成功
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。