springboot 集成swagger ui
2024-10-19 14:27:59
1. 添加依赖
<!-- swagger ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.2.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.2.2</version>
</dependency>
2. 启动swagger ui注解
@SpringBootApplication
@EnableSwagger2
public class Main { public static void main(String[] args) throws Exception {
SpringApplication.run(Main.class, args);
}
}
3.添加 controller注解
@RestController
@RequestMapping("/user")
@Api("swagger ui 注释 api 级别")
public class HelloWorldController { @ApiOperation("swagger ui 注释 方法级别")
@RequestMapping(value="/hello",method=RequestMethod.GET)
public String hello() {
String data = "Never trouble untill trouble troubles you. Some one told me some years ago.";
return data;
}
}
4. swagger ui 链接: localhost:8080//swagger-ui.html (默认)
最新文章
- jquery.validate 使用--验证表单隐藏域
- 安装 modelsim 10.4
- HashTable、HashMap、HashSet
- lua语法备忘录
- JQuery选择器使用
- 制作BibTex文件
- 一个int类型究竟占多少个字节
- View原理
- hdu 1814 Peaceful Commission (2-sat 输出字典序最小的路径)
- 11 款最好 CSS 框架
- Android如何调用第三方SO库(转)
- 一些很容易被忘记的css
- Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment:
- python-迭代器、生成器、内置函数及面向过程编程
- 20181014xlVBA获取小题零分名单
- 6 云计算系列之Nova安装与配置
- Number常用方法函数
- 如何将同一 VNET 下的虚拟机从经典部署模型迁移到 Azure Resource Manager
- 使用RunWith注解改变JUnit的默认执行类,并实现自已的Listener
- Selenium2+python自动化
热门文章
- [Docker] Download and Remove Docker Images
- Python 标准库和第三方库的安装位置、Python 第三方库安装的各种问题及解决
- 小强的HTML5移动开发之路(47)——jquery mobile基本的页面框架
- 【codeforces 754A】Lesha and array splitting
- springmvc中controller内方法跳转forward?redirect?
- [NPM] Run npm scripts in series
- Xcode编译Undefined symbols for architecture xxx 错误总结
- 【26.09%】【codeforces 579C】A Problem about Polyline
- Android开发之assets目录下资源使用总结
- 不安装 oracle的客户,就可以使用pl/sql访问远程oracle 数据库的方法