⌨️ @SpringBootApplication
@SpringBootApplication
public class SpringBootDeveloperApplication {
public static void main(String[] args) {
SpringApplication.run(SpringBootDeveloperApplication.class, args);
}
}
@SpringBootApplication
⌨️ TestController.java
@RestController
public class TestController{
@GetMapping("/test")
public String test() {
return "Hello, world!";
}
@RestController
- 라우터와 같이 HTTP 요청과 메서드를 연결하는 역할을 한다.
- GET /test 요청이 들어오면 test( ) 함수를 실행한다.
- @Controller + @ResponseBody
- @Controller 속 @Component 존재.
- @Component가 있는 class는 빈으로 등록된다.
빈이란?