Another Brain

39일차(7월 13일)_ Spring Boot 환경설정 본문

P/Web

39일차(7월 13일)_ Spring Boot 환경설정

뉸누나ㄴ나 2021. 7. 13. 18:20
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 

-- Spring Tool Suite (STS)
-- eclipse marketplace 추가 설치
-- sts 별도 설치 
-- spring.io 웹에서 프로젝트 생성 방법


## 다운로드 설치
1. STS download
-- https://spring.io/
-- .jar
>> power shell
>> .jar 파일 윈도우 탐색기 >> shift + 우클릭 power shell 실행 >> [ps] java -jar spr + tab 키 누르면 자동완성
-- .zip

-- 설치폴더 : C:\00.practice\sts-4.10.0.RELEASE>

-- Spring Boot 
>> WAS 자체 내장
>> Tomcat 내장 : 기본 port="8080"


2. STS 초기 환경설정
-- C:\00.practice\sts-4.10.0.RELEASE> SpringToolSuite4.ini
-- 변경:
>> -Dosgi.requiredJavaVersion=1.8
>> -Xms1024m


3. STS 실행
-- C:\00.practice\sts-4.10.0.RELEASE> SpringToolSuite4.exe


4. Workspace 작업폴더
-- C:\00.practice\workspace_springboot>


5. Spring boot : JSP를 사용하기위한 플러그인 추가 설치폴더
-- STS > Help > Eclipse Marketplace > Find: jsNature > Web Developer Tools 추가 설치 (수업에는 jsp 포함되어있는 것으로)


6. Workspace 환경 설정
-- encoding
-- Java
-- Browser
-- Font


7. Emmet HTML auto tag 생성 에디터 추가??
-- http://emmet.io/

-- STS > Help > Install New Sofware > Add
>> Name: Emmet
>> Location: http://emmet.io/eclipse/updates
>> Emmet 체킹 설치

-- 설치 후 jsp에서도 사용하기 위한 환경설정 추가
>> Eclipse >> Window >> Preferences >> Emmet 
>>  in Files extension >> 기존뒤에 추가 ..., jsp, jspf 


8. Spring Boot 프로젝트 생성
-- 프로젝트 생성시에 의존관계 라이브러리로 Lombok 설치하기
>> Lombok 도메인클래스 자동 메서드 제공 플러그인

-- Maven, Gradle : 
>> 의존관계 라이브러리 자동관리 오픈소프 프레임워크 
>> pom.xml
>> 프로젝트 생성시 선택 추가

-- 프로젝트 생성
>> File >> NEW >> Spring Starter Project
>> 의존관계 기본 추가 : Spring Web, Spring Boot DevTools, Lombok

-- 프로젝트 실행    
>> Run As >> Spring Boot App
>> 실행 후 Console 메세지 확인 : 오류, 정상 여부 체킹


9. Lombok 패치 작업하기
-- lombok.jar 파일 있는 윈도우 탐색기 이동하기
=> C:\Users\Playdata\.m2\repository\org\projectlombok\lombok\1.18.20> 
-- power shell 실행 : shift + 우클릭
-- [PS] > java -jar lombok-1.18.20.jar
-- lom 입력 하고 tab 키 누르면 자동 완성 

-- Install >> Specify Location 클릭 >> STS4 설치 폴더에 있는 SpringToolSuite4.exe 파일 선택 >> Install/Update >> 종료

10. STS File >> Restar(재구동) >> Exit(종료)

11. C:\00.practice\sts-4.10.0.RELEASE> SpringToolSuite4.ini 환경설정 추가
-- 롬복패치 추가된것 확인
-- 맨아래에 아래 jdk 추가

-vm
C:\Program Files\Java\jdk1.8.0_202


12. STS4 설치 및 환경설정 작업 완료


## 스프링부트 프로젝트 폴더 구조 및 구성요소
-- pom.xml
>> maven 기반의 의존관계 라이브러리 설정 파일
>> 프로젝트 생성시에 의존관계 라이브러리 선택 추가
>> pom.xml 직접 의존관계 추가

-- Maven Repository 에서 의존관계 복사해서 pom.xml 추가 
>> https://mvnrepository.com/


-- 환경설정
>> src/main/resources>
>> application.properties
server.port=8070

>> application.yml
server:
  port: 8070


>> src/main/resources/static>  
>> html, css, js, img etc.


>> src/main/resources/templates> 
>> 타임리프(thymeleaf) view => html5


## [실습]
-- HomeController : @Controller, @RequestMapping, @ResponseBody
-- Member : Lombok : @Setter @Getter @NoArsConstructor @Data
-- test.html : Emmet Auto Tag 
-- see:
>> https://projectlombok.org/ >> https://projectlombok.org/features/all
>> https://emmet.io/ >> https://docs.emmet.io/abbreviations/syntax/

-- src/main/java>
>> com.example.demo.controller.HomeController
>> com.example.demo.dto.Member

-- src/main/resources>
>> static >> test.html


Spring Boot 

Tab 

 

 

 

Window - Preferences - Run/Debug - console

 

 

## STS MarketPlace 수행중 오류발생 해결방법  -- SpringToolSuite4.ini 파일에 추가
-Djava.net.preferIPv4Stack=true

Comments