带有弹簧靴 2.0 的摇摆不定导致 404 错误页面
我正在尝试将我的Spring Boot版本与Swagger集成。2.0.1.RELEASE
从这篇博客文章中可以看出,只需添加两个Maven依赖项即可轻松完成,一切都应该可以正常工作。
因此,我在 pom 中添加了以下依赖项:
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.8.0</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.8.0</version>
</dependency>
并创建了豆子:SwaggerConfig
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket api() {
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
}
在属性文件中,在尝试使其工作时,我最终得到了以下3个条目:
spring.application.name=cat-service
management.server.servlet.context-path=/cat-service
server.servlet.contextPath=/cat-service
但最后,当访问时
http://localhost:8080/cat-service/api/v2/api-docs
或 UI 页面位于
http://localhost:8080/cat-service/swagger-ui.html
我收到一个错误。page not found
我在swagger github页面中发现了这个问题,在stackoverflow中发现了这个问题,但我无法更改我的错误。404
 
					 
				 
				    		 
				    		 
				    		 
				    		