본문 바로가기
Spring Boot

[Spring Boot] Hello World 프로젝트 생성

by palbokdev 2021. 4. 13.

IDE : IntelliJ

 

  1. 메인 메뉴에서 File | New | Project 선택
  2. 좌측 메뉴에서 Spring Initializr 선택
  3. SDK 선택 (없다면 다운로드 가능)
  4. https://start.spring.io/ 선택 후 다음으로 이동
  5. 프로젝트 setting 기본값으로 두고 다음으로 이동
  6. Web 선택 후 우측에 Spring Web 선택 후 다음으로 이동
  7. 프로젝트 configuration 기본값으로 두고 프로젝트 생성

DemoApplication.java 작성

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 sayHello(@RequestParam(value = "myName", defaultValue = "World") String name) {
        return String.format("Hello %s!", name);
    }
}

 

실행 후 http://localhost:8080/hello 접속

 

ref : www.jetbrains.com/help/idea/your-first-spring-application.html