개발 공부/Spring

[SpringBoot] REST API & IntelliJ 프로젝트생성

journey 2022. 2. 16. 00:26
728x90

02. Hello World API

1. REST Client 설치

chrome 설치

Talent API

Postman API

2. 스프링부트 프로젝트 생성 (IntelliJ IDEA)

  • New Module 생성

  • Dependencies 추가

3. 스프링 부트 서버 실행

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController                 // 해당 class는 REST API 처리하는 Contorller
@RequestMapping("/api")     // RequestMapping URI를 지정해주는 Annotation. 주소 할당
public class ApiController {

    @GetMapping("/hello")   // http://localhost:8080/api/hello
    public String hello() {
        return "hello spring boot!";
    }

}

'개발 공부 > Spring' 카테고리의 다른 글

[SpringBoot] REST API - PUT  (0) 2022.02.16
[SpringBoot] REST API - POST  (0) 2022.02.16
[SpringBoot] REST API - GET  (0) 2022.02.16
[SpringBoot] 스프링 부트란  (0) 2022.02.14
[Spring boot] Lombok 사용하기  (0) 2022.01.11