[Spring Boot ] Creating the Spring Boot Project : Demo: Creating a REST Controller
Posted answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Spring Boot ] Creating the Spring Boot Project : Demo: Creating a REST Controller相关的知识,希望对你有一定的参考价值。
In Spring boot, define a REST API endpoint is pretty easy.
package com.globomatisc.bike.controllers; import java.util.ArrayList; import java.util.List; import com.globomatisc.bike.models.Bike; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.*; @RestController @RequestMapping("/api/v1/bikes") public class BikesController { @GetMapping public List<Bike> list() { List<Bike> bikes = new ArrayList<>(); return bikes; } @PostMapping @ResponseStatus(HttpStatus.OK) public void create(@RequestBody Bike bike) { } @GetMapping("/{id}") public Bike get(@PathVariable("id") long id) { return new Bike(); } }
以上是关于[Spring Boot ] Creating the Spring Boot Project : Demo: Creating a REST Controller的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot报错:Error creating bean with name 'sqlSessionFactory' ...
Error creating bean with name 'org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration
spring-boot导入redis依赖后报错 Error creating bean with name ‘redisConnectionFactory‘
Error creating bean with name 'org.apache.cxf.spring.boot.autoconfigure.CxfAutoConfiguration(示例代
spring boot maven install时报错 Error creating bean with name 'serverEndpointExporter'
@WebMvcTest 在 Spring Boot 测试中为不同服务提供“Error Creating bean with name”错误