标签:style artifact img boot api lin source nis lang
1.1 maven项目
1.2 设置项目名
1.3 设置本地maven
1.4 finish
打开pom文件,添加下面的依赖
[sourcecode language=‘xml‘ padlinenumbers=‘true‘] <!--swagger--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.6.1</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.6.1</version> </dependency> [/sourcecode]
[sourcecode language=‘java‘ ] @Configuration @EnableWebMvc @EnableSwagger2 public class SwaggerConfig { @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.whu505.controller")) .paths(PathSelectors.any()) .build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("Person RESTful API文档") .description("Person Controller的文档") .termsOfServiceUrl("") .version("1.0") .build(); } } [/sourcecode]
SpringMVC整合Swagger(非Spring Boot)
标签:style artifact img boot api lin source nis lang
原文地址:https://www.cnblogs.com/GIS-Lu/p/9774534.html