상세 컨텐츠

본문 제목

SpringBoot를 사용하여 "hello spring boot" 출력하기

Back-end/JavaSpringBoot

by 본투비곰손 2022. 8. 16. 21:52

본문

728x90
package com.example.newprojects.controller;

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를 처리하는 Controller
    @RequestMapping("/api") //RequestMapping URI를 지정해주는 Annotation
public class ApiController {

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

 

728x90

'Back-end > JavaSpringBoot' 카테고리의 다른 글

POST API  (0) 2022.08.16
Get API  (0) 2022.08.16
스프링 부트 란?  (0) 2022.08.04
HTTP Protocol  (0) 2022.08.04
URI 설계 패턴  (0) 2022.08.04

관련글 더보기