SpringBoot集成Swagger
引入依赖
<!-- /artifact/io.springfox/springfox-swagger2 --><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.9.2</version></dependency><!-- /artifact/io.springfox/springfox-swagger-ui --><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>2.9.2</version></dependency>
编写HelloController,测试确保运行成功!
package com.xxxx.swagger2.controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class HelloController {@RequestMapping(value = "/hello")public String hello(){return "hello";}}
要使用Swagger,我们需要编写一个配置类-SwaggerConfig来配置 Swagger
@Configuration //配置类@EnableSwagger2// 开启Swagger2的自动配置public class SwaggerConfig {}
访问测试 :http://localhost:8080/swagger-ui.html ,可以看到swagger的界面;
如果觉得《[Swagger2]SpringBoot集成Swagger》对你有帮助,请点赞、收藏,并留下你的观点哦!