swaggerを使用してUnable to infer base urlが現れる.This is common when using dynamic servlet...
4890 ワード
このような状況を解決する方法:
コンフィギュレーションクラスSwaggerConfigを作成します(ここでは手動で作成し、コピーしないでください):
次にアイテムを起動し、アドレスバーに入力します.http://localhost:8300/swagger-ui.html
<!-- swagger2 -->
<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>
コンフィギュレーションクラスSwaggerConfigを作成します(ここでは手動で作成し、コピーしないでください):
@Configuration
@EnableSwagger2
public class SwaggerConfig {
// Swagger Docket bean
@Bean
public Docket docket(){
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("tom")
.select()
.apis(RequestHandlerSelectors.basePackage("com.alibaba.seata.controller"))
// .paths(PathSelectors.ant("/hello/**"))
.build();
}
// swagger APIinfo
public ApiInfo apiInfo(){
//
Contact contact = new Contact("tom", "https://mail.qq.com/", "[email protected]");
return new ApiInfo(
"Tom Swagger API ",
" Java ",
"1.0",
"https://mail.qq.com/",
contact,
"Apache 2.0",
"http://www.apache.org/licenses/LICENSE-2.0",
new ArrayList<>());
}
}
次にアイテムを起動し、アドレスバーに入力します.http://localhost:8300/swagger-ui.html