标签:return str operation ima enc htm web group 添加
1、添加pom依赖:
<!-- 添加swagger相关依赖 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
2、启动类上添加@EnableSwagger2注解:
@EnableSwagger2
3、在Controller类上添加@Api注解,方法上添加@ApiOperation注解:
package cn.mmweikt.es.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("test")
@Api("测试")
public class TestController {
@GetMapping("test1")
@ResponseBody
@ApiOperation("测试")
public String test(){
return "test1";
}
}
4、访问http://127.0.0.1:8080/swagger-ui.html验证:
标签:return str operation ima enc htm web group 添加
原文地址:https://www.cnblogs.com/kibana/p/10317555.html