我正在运行一个SpringBoot配置服务器(使用Vault后端),并尝试将Springfox SwaggerUI添加到其中。但是,由于我不希望配置服务器使用前缀(spring.cloud.config.server.prefix),因此配置服务器和SwaggerUI之间的路径映射会导致冲突。
我的所有客户端都会使用以下模式询问配置服务器:
{config-server-host}/{application-name}/{profile}例如:
{config-server-host}/test-app-one/dev
{config-server-host}/test-app-two/prod但是我的SwaggerUI路径映射到:
{config-server-host}/swagger-ui.html因此,配置服务器会抱怨找不到应用程序"swagger-ui“,或者没有指定配置文件。
下面是SwaggerUI的Docket bean的配置:
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.paths(not(regex("/error.*")))
.paths(any())
.build()
.pathMapping("/");
}
private ApiInfo apiInfo() {
Contact contact = new Contact({secret}, {secret}, {secret});
return new ApiInfoBuilder().title({secret})
.description({secret})
.version({secret})
.contact({secret})
.build();
}
}这一切都会导致以下问题:我不能有配置服务器的前缀,我希望将SwaggerUI url映射到标准。是否可以告知配置服务器应该排除/swagger*路径?
发布于 2020-10-03 17:57:05
bootstrap.properties文件中的spring.cloud.config.server.prefix参数为我修复了这个问题。
https://stackoverflow.com/questions/52878243
复制相似问题