카테고리 없음
spring boot - web 프로젝트
너도
2024. 2. 23. 19:07
pom.xml 에 추가
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
재기동을 하면
Tomcat initialized with port 8080 (http)
Starting service [Tomcat]
Starting Servlet engine: [Apache Tomcat/10.1.18]
Initializing Spring embedded WebApplicationContext
Root WebApplicationContext: initialization completed in 673 ms
Tomcat started on port 8080 (http) with context path ''
8080 포트로 서버가 올라 간 것을 확인할 수 있다.
controller를 하나 달고
package com.urbug2.web.sample.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SampleController {
@RequestMapping("/sample/")
public String hello() {
return "Hello world";
}
}
호출해 보면 정상 호출되는 것을 확인