我更喜欢的文档配置
依赖
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<!-- <version>3.0.3</version>-->
<version>2.0.8</version>
</dependency>
必备配置
spring.mvc.pathmatch.matching-strategy=ant_path_matcher
配置类
@Configuration
@EnableSwagger2WebMvc
//@Profile("develop")
public class Knife4jConfig {
@Bean
public Docket defaultApi2() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfoBuilder()
.title("projectName")
.description("description")
.version("1.0")
.build())
.select()
// 指定 Controller 扫描包路径
.apis(RequestHandlerSelectors.basePackage("com.carplay.controller"))
.paths(PathSelectors.any())
.build().groupName("develop");
}
}
访问地址
http://localhost:9999/car/doc.html