IDE : IntelliJ
- 메인 메뉴에서 File | New | Project 선택
- 좌측 메뉴에서 Spring Initializr 선택
- SDK 선택 (없다면 다운로드 가능)
- https://start.spring.io/ 선택 후 다음으로 이동
- 프로젝트 setting 기본값으로 두고 다음으로 이동
- Web 선택 후 우측에 Spring Web 선택 후 다음으로 이동
- 프로젝트 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
'Spring Boot' 카테고리의 다른 글
[Spring] CrudRepository vs JpaRepository (0) | 2021.10.13 |
---|---|
[Spring] 매일 자정 특정 동작 수행하기 (schedule, cron) (0) | 2021.10.12 |
[Spring] @Controller vs @RestController (0) | 2021.09.17 |
[JPA] FetchType Eager와 Lazy 차이점 (0) | 2021.04.30 |
[JPA] @Transient (0) | 2021.04.27 |