솔적솔적

Spring Boot 프로잭트 생성 본문

Back-end/Spring Boot

Spring Boot 프로잭트 생성

카드값줘체리 2022. 1. 25. 00:04

프로젝트 생성하려면 먼저

 

1. JAVA 11설치 

2. IDE: IntelliJ 또는 Eclipse 설치 또는 spring 설치(이걸로 실행 진행)

 

 

| 프로젝트 생성

https://spring.io/tools

 

Spring Tools 4 is the next generation of Spring tooling

Largely rebuilt from scratch, Spring Tools 4 provides world-class support for developing Spring-based enterprise applications, whether you prefer Eclipse, Visual Studio Code, or Theia IDE.

spring.io

각 운영체제에 알맞게 버튼 눌러 다운로드 → 압축파일 생김 → 압축풀기

 

압축을 풀면

만약 이 SpringToolSuite4가 안보일경우 다시 설치하기(안 보여서 처음부터 설치하니 나옴..)

 

File → New → Spring Starter Project 

 

 

Finish를 누르면 프로젝트가 생성됩니다.

 

실행하면 콘솔부분에서 귀엽게 스프링의 실행을 반겨주고
웹브라우저창에 검색 시작!
웹브라우저 부분에 아무것도 안넣었으니 아직까지는 Error Page가 나오는 것이 정상

 

| View 생성

src/main/resources 안에 index.html 생성

src/main/resources/index.html 

<!DOCTYPE HTML>
<html>
<head>
 <title>스프링부트 프로젝트 뷰 생성</title>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
프로잭트생성 완료
</body>
</html

다시 실행해보면

 

이제 controller를 사용하여 View를 브라우저에 html이 보여지게 해보자.

 

src/main/java에 패키지 Controller생성 →helloController 생성

 

 

src/main/resourses → templates → hello.html 생성 

껏다가 다시 실행

 

 

 

spring 사이트에 들어가서 사이트 내에 작성 후 압축파일을 생성하여 import하는 방법도 있다.

| 사이트로 이동해서 스프링 프로젝트 생성하는 방법

https://start.spring.io/

 

 

 

ADD Dependencies 부분 클릭하여

Spring web 그리고 thyme 검색하여 설정

하고 새폴더(작명) 만들고 sts tool에 import하기 

 

 

[참고자료] 인프런 스프링 입문 - 코드로 배우는 스프링 부트, 웹 MVC, DB 접근 기술