[Spring boot] 시작하기1

Ho·2022년 6월 22일
0

Spring Boot 입문

목록 보기
1/7

spring boot란?

스프링 부트(Spring Boot)는 스프링(Spring)을 더 쉽게 이용하기 위한 도구라고 볼 수 있습니다. 스프링 이용하여 개발을 할 때, 간단하게 프로젝트를 설정할 수 있게 하여, Spring 개발을 조금 더 쉽게 만들어주는 프레임워크이다.

spring boot 시작하기

https://start.spring.io/

  • 위의 url 에 접속하여 spring boot 프로젝트를 생성할 수 있다.
  • gradle을 선택하고 dependencies에 spring web, thymeleaf를 추가하여 라이브러리를 포함한 간단한 스프링부트 프로젝트를 생성할 수 있다.
  • 설정을 완료하고 generate를 누르면 프로젝트가 다운된다.
  • intelliJ를 통해 해당 프로젝트의 build.gradle을 열면 프로젝트가 열린다.

빌드하고 실행하기

  1. resources/static 경로에 index.html을 작성하여 url로 접속시 나타낼 html 페이지를 작성한다.
<!DOCTYPE HTML>
<html>
<head>
    <title>Hello</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
Hello
<a href="/hello">hello</a>
</body>
</html>
  1. 스프링부트 어플리케이션을 실행하면 내장되어있는 톰캣 서버가 실행된다.
package hello2.hello2spring;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Hello2SpringApplication {

	public static void main(String[] args) {
		SpringApplication.run(Hello2SpringApplication.class, args);
	}

}
  1. 웹브라우저에서 localhost:8080로 실행된 어플리케이션의 결과를 볼 수 있다.

0개의 댓글