Spring boot 如何在swagger-ui.html之前添加/api

Spring boot 如何在swagger-ui.html之前添加/api,spring-boot,swagger-ui,request-mapping,Spring Boot,Swagger Ui,Request Mapping,如何在swagger-ui.html之前添加默认参数 像这样: http://localhost:8080/api/swagger-ui.html 到目前为止,我整合了以下内容: Pom.xml: <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.

如何在swagger-ui.html之前添加默认参数

像这样:

http://localhost:8080/api/swagger-ui.html
到目前为止,我整合了以下内容:

Pom.xml:

<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>

试试这个:

new Docket(DocumentationType.SWAGGER_2)
    .host("www.mydomain.com")
    .pathProvider(new RelativePathProvider(servletContext) {
        @Override
        public String getApplicationBasePath() {
            return "/myapi";
        }
    });

如果遇到任何问题:

请在swagggerconfig.java中的类级别包含以下注释:

@Configuration
@EnableSwagger2
public class SwaggerConfig {                                    
    @Bean
    public Docket api() { 
        return new Docket(DocumentationType.SWAGGER_2)  
          .select()                                  
          .apis(RequestHandlerSelectors.any())              
          .paths(PathSelectors.any())                          
          .build();                                           
    }
}

Do I have to map "swagger-ui.html" to something with @RequestMapping?
@PropertySource(“classpath:swagger.properties”)和 @组件扫描


然后在resources目录中创建swagger.properties文件(与application.properties文件位于同一位置)

考虑查看此文档,我是否可以直接在application.yml中添加server.servlet=/api?