搭建一个REST API服务并不是一件容易的事 - 从顶层设计到使一切工作良好。
REST作为Spring的一等公民,随着平台的完善和伴随着Spring 5的发布,REST现在变的更加健壮和成熟。
本教程从基础开始 - 教你如何搭建REST服务, Spring MVC 配置, 基础自定义。
然后深入REST高级主题 - HATEOAS,分页, 错误处理与测试。
REST API 基础
- 搭建一个 Web 应用
- 构建REST API
- Spring @Controller 与 @RestController 注解
- REST 错误处理 (热门)
- Entity 到 DTO之间的转换
- Spring RequestBody 和 ResponseBody 注解
- Spring REST Controller中如何读取HTTP header
- 使用Spring @ResponseStatus设置HTTP状态码
- 使用 Spring ResponseEntity 操作 HTTP Response
REST API 高级话题
- Spring REST API 与 Swagger 2的集成
- 使用OpenAPI 3.0 为 Spring REST API 提供文档
- Spring 错误 Request Method Not Supported (405)
- HATEOAS for a Spring REST Service
- REST API Discoverability and HATEOAS
- Versioning a REST API
- REST Pagination
- ETags for REST
- Spring MVC Content Negotiation
- Spring REST API with Protocol Buffers
- A Custom Media Type for a Spring REST API
- Handling URL Encoded Form Data in Spring REST
- Generate Spring Boot REST Client with Swagger
- Spring REST API + OAuth2 + Angular (popular)
测试 & 消费API
- Test a REST API with Java
- The Guide to RestTemplate
- RestTemplate Post Request with JSON
- RestTemplate with Basic Authentication
- Get and Post Lists of Objects with RestTemplate
- Configure a RestTemplate with RestTemplateBuilder
- Spring RestTemplate Error Handling
- Uploading MultipartFile with Spring RestTemplate
- Spring WebClient vs. RestTemplate
- Spring WebClient Requests with Parameters
- Spring WebClient Filters
- Spring WebClient and OAuth2 Support
- Spring RestTemplate Request/Response Logging
- Reading an HTTP Response Body as a String in Java
其他Spring教程
- Spring持久化教程
使用Spring Hibernate, JPA, Spring Data等构建应用持久层。 - Spring Exceptions教程
Spring中常见的异常-为何发生以及如何快速解决它们。 - Spring Security
How to Secure an MVC project, Login and Logout, how to Secure a REST Service, Basic and Digest Authentication with Spring Security 如何保护一个MVC应用,登录和注销,如何保护REST服务,使用Spring Security完成Basic、Digest身份验证。