Springboot快速构建restful接口
来源:互联网 发布:淘宝有好货报名入口 编辑:程序博客网 时间:2024/05/18 03:57
demo目录结构如下:
这里用到了lombok,在pom文件中引入依赖
<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.16.10</version></dependency>
在Intellij idea中快速构建Springboot web工程,
创建User类:
@Data@NoArgsConstructorpublic class User { private String username; private String password; public User(String username, String password) { this.username = username; this.password = password; }}创建UserController类:
@RestControllerpublic class UserController { @RequestMapping("/user") public User helloUser(@RequestParam(value="username",defaultValue = "tomcmd") String username, @RequestParam(value = "password",defaultValue = "123456") String password){ return new User(username,password); }}
启动类代码,这里不需要更改
@SpringBootApplicationpublic class Demo01Application {public static void main(String[] args) {SpringApplication.run(Demo01Application.class, args);}}配置文件:application.properties中可以配置启动端口
server.port=8000最后,启动工程,浏览器中访问localhost:8000/user?username=root&password=123,结果如下:
阅读全文
0 0
- Springboot快速构建restful接口
- springboot中使用swagger2构建restful接口文档
- springBoot构建Restful服务
- 快速构建SpringBoot程序
- SpringBoot集成springfox-swagger2构建restful API
- SpringBoot之构建Restful API与单元测试
- 使用SpringBoot快速构建应用程序
- springboot+maven快速构建项目
- springBoot maven快速构建项目
- SpringBoot构建RESTful API——基础构建
- golang 快速构建Restful API服务
- SpringBoot构建RESTful API——处理返回异常
- springboot【3】web开发之构建RESTful API与单元测试
- Springboot中使用Swagger2构建RESTful API文档
- 【转】SpringBoot集成springfox-swagger2构建restful API
- springboot集成swagger2,构建优雅的Restful API doc
- SpringBoot快速构建微服务架构体系
- SpringBoot快速入门-基本项目构建
- Ramda 函数库
- ijkplayer iOS11播放只有声音没有图像
- centos7搭建ftp服务器
- 虚拟机的安装 虚拟机快照
- java代码生成条形码
- Springboot快速构建restful接口
- LoadRunner性能压测示例
- 1.开始我的整理之路
- 互联网+助力恒德智能装备远程自动化控制
- Python Web开发
- 什么时候使用CountDownLatch
- 每日一练 20171110
- 使用python selenium TouchAction模拟实现lCalendar滚动和点击效果
- 准备报考信息系统项目管理工程师中级职称