高效的RESTfulAPI服务实现,基于Jersey2和嵌入式的轻量级的servlet容器Jetty9,这个是war包形式部署到jetty中运行,实现对用户的增、删、改、查操作,并且严格按照RESTful风格设计接口。
基于Jersey2+Spring4+MyBatis3+Jetty9实现,完全遵循OpenAPI设计规范,供开发WebAPI的开发人员做一个参考实现,并很容易在此基础上扩展功能。
接口演示:
根据id获取用户信息https://localhost/api/v1/users/1结果:
{ "id" : 1, "name" : "张飞", "age" : 20, "password" : "zhangfei", "createdTime" : "2017-06-15 20:38:09", "updatedTime" : "2017-06-15 20:38:09"}
注:下面几种使用chrome的Postman测试
创建新用户https://localhost/api/v1/usersPOST
body参数:
{ "id" : 3, "name" : "孙权", "age" : 24, "password" : "sunquan"}返回结果:
HTTP code:201User was successfully created更新用户https://localhost/api/v1/usersPUT
body参数:
{ "id" : 3, "name" : "孙权", "age" : 25, "password" : "sunquan"}返回结果:
HTTP code:200User was successfully updated
评论