본문 바로가기

Spring

스프링부트 퀵스타트

728x90

https://spring.io/quickstart

project name: demo

처음 자동 생성되는 (*Project name)Applicaton.java (DemoApplication.java) 파일의 클래스(DemoApplication)에 @RestController 어노테이션 붙이고 @GetMapping

 

package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
public class DemoApplication {
    public static void main(String[] args) {
      SpringApplication.run(DemoApplication.class, args);
    }
    @GetMapping("/hello")
    public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
      return String.format("Hello %s!", name);
    }
}

 

https://wikidocs.net/160444

 

1-04 스프링부트 맛보기

* `[완성 소스]` : [https://github.com/pahkey/sbb3/tree/1-04](https://github.com/pahkey/sbb3/tree/1-04) …

wikidocs.net

새로 생성한 클래스에 @Controller 어노테이션 붙이고 @GetMapping + @ResponseBody

 

ERROR>>

@Controller 안붙이고 썼더니 계속  404 에러 ㅠㅠ

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Mon Apr 10 03:30:33 KST 2023

There was an unexpected error (type=Not Found, status=404).
728x90