메뉴 건너뛰기

조회 수 4160 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

Spring Boot 프로젝트 생성


Spring Starter Project 실행




File > New > Spring Starter Project (선택)


 

 

 

 




Spring Boot 사용을 위해 Packaging 은 Jar 선택


Next > New Spring Starter Project



Dependencies 선택

Core : DevTools

SQL : MySQL

Template Engines : Velocity

Web : Web


* 선택한 요소들은 pom.xml 파일에 반영 됩니다.

* Frequently Used : 과거 프로젝트 생성시 선택했던 항목 표기 (처음 설치시 나오지 않음) 



Dependencies Template Engines (템플릿 엔진)


Freemarker:  spring-boot-starter-freemarker 
Velocity:  spring-boot-starter-velocity 
Groovy Templates:  spring-boot-starter-groovy-templates 
Thymeleaf:  spring-boot-starter-thymeleaf 
Mustache:  spring-boot-starter-mustache 

어떤걸 사용할지 고민중~~ 좀더 찾아보고~~



Next > Site Info

 

 

 

 

 



 프로젝트 구성 중, 뭘 그리 받아야 하는지~~ 

 

 

 

 

 

 

생성된 프로젝트 패키지 구조


Hello World 실행 페이지 개발


1. index.html 을 통한 Hello World 웹 페이지 실행

 

index.html 추가

Package Explorer > src/main/resources > static 폴더에 "index.html" 생성


 

 

 

 

  

Hello World Sample Code

   <!DOCTYPE html>
  <html lang="ko">
  <head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta http-equiv="Content-Language" content="ko">
  <title>Spring Boot Hello World</title>
  </head>
  <body>

  <h1>Spring Boot Hello World</h1>

  </body>
  </html> 

 

 

 

 

  

​index.html 실행



Spring Boot App 실행



Console > Spring Boot 실행 확인


 

 

 


기본 포트인 8080 으로 Spring Boot App 실행 확인 

( netstat -an | find "8080" )



 

 

 

 

 웹 브라우저에서 index.html 실행 확인

 

 http://localhost:8080 브라우저에서 실행 성공

만약 권한 오류등이 나온다면, Dependencies 에서 Hello World 용으로만 설치 권장 ^^

기본 포트 8080 이 이미 사용중 이라면 catalina.properties 나 application.properties 설정 변경



2. Controller 를 통한 Hello World 출력 


 

 

 

 

 

WEB 코드 저장 Package 생성, "Paccom.example.web"

 


Class 작업용 "HelloWorld.java" 생성, 이크 네이밍룰 미적용 ㅠㅠ"

 


HelloWorld Sample Code

package com.example.web;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HelloWorld {

 @RequestMapping("/helloworld")
 public @ResponseBody String helloworld() {
  return "Spring Boot Hello World";
 }
}
 


HelloWorld Controller 코드 등록 후 Spring Boot 재 시작


 


실행 결과



List of Articles
번호 제목 날짜 조회 수
71 다형성 file 2016.09.13 3260
70 예외 처리 기본 file 2016.09.13 3249
69 오토박싱 2016.09.13 3246
68 익명클래스 2016.09.13 3143
67 public static void main(String [] args) 2016.09.13 3143
66 for-each문 file 2016.09.13 3120
65 데몬쓰레드 2016.09.13 3099
64 인터페이스 2016.09.13 3089
63 자바 정규식 마스킹처리 file 2018.06.26 2631
62 JAVA 두개의 문서 파일 비교하기 2018.07.09 2388
61 숫자형식 포멧 방법 2018.02.09 2342
60 JAVA CentOS JDK 설치 및 환경변수 설정 file 2018.07.09 1821
59 사용자의 IP를 가져오기 (IPv4) 2020.06.29 1693
58 JDK 9에서 eclipse 실행이 안될때 2018.06.05 1596
57 JAVA 이클립스 인코딩 변경하기 file 2018.07.09 1590
56 JAVA TreeMap 인덱스 값 가져오기 및 Collections.sort 사용하기 2018.07.09 1487
55 이클립스 html, js 등등의 파일에서 에러표시 지우기 2019.03.05 1447
54 자바 날짜 포맷 변환 방법 file 2018.06.21 1425
53 JAVA JDK 제거하기 file 2018.07.09 1409
52 변환 (문자, 숫자, KSC5601.....) 2019.01.16 1281
Board Pagination Prev 1 2 3 4 5 6 7 8 Next
/ 8

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved