赞
踩
<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>
Swaager不是springboot生态,所以需要新建配置类
配置类可以实现代码控制开启关闭、扫描包等功能,可以自行搜索
这里的配置类是空的,但是能用来启动Swaager
package com.greentran.origin.config;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
}
package com.greentran.origin.controller; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.beans.factory.annotation.Value; @Validated @RestController @RequestMapping("/user") public class userController { @PostMapping(value = "login") public String login() { return "登录返回值"; } }
项目地址+端口+swagger-ui.html
例如:http://localhost:8080/origin/swagger-ui.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。