sts 설치를 끝냈으니 간단하게 프로젝트를 하나 만들어 보도록 하겠습니다.
[File] - [New] - [Spring Starter Project] 메뉴를 선택해서 프로젝트 생성 창을 열어주세요.
개발 목적에 따라 Type, Packaging 등을 설정 할 수 있지만 지금은 간단하게 web 프로젝트를 만들거라 Name만 변경해주고 Gradle Build의 Dependency 는 Web을 선택했습니다.
프로젝트가 생성되면 HelloWorldController 라는 클래스를 하나 만들어 주세요.
HelloWorldController.java 에 아래와 같이 코드를 추가해주세요.
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorldController {
@RequestMapping("/")
public String test() {
return "Hello world!";
}
}
[HelloWorld 프로젝트 선택] - [우 클릭] - [Run As] - [Spring Boot App] 순서대로 서버를 실행해줍니다.
Spring Boot는 별도로 tomcat 을 추가해 주지 않아도 돼서 편리한 것 같네요.
웹 브라우저를 실행해서 http://localhost:8080 로 접속하면 아래와 같이 화면이 출력 되는 걸 확인할 수 있습니다.
'프로그래밍 > Web' 카테고리의 다른 글
Spring Boot를 이용한 Web 개발 환경 구성하기 (0) | 2018.12.14 |
---|
댓글