Back-End/SpringBoot

스프링부트와 AWS로 혼자 구현하는 웹 서비스 (chap.1) - 프로젝트 생성

Young-Cow 2021. 1. 12. 22:16

*이해를 위해 메모장처럼 활용한 포스트로, 신뢰하지 말고 참고용으로 활용

 

1. 인텔리제이(IntelliJ) 설치

인텔리제이 커뮤니티 설치를 위해 Toolbox app을 먼저 설치

버전 관리가 쉬움

최신 버전 2020.3 이 있었으나, 책에서는 2019.2.4 를 사용해서 인터페이스나 설정하는 것들이 차이가 남

그래서 툴박스에서 제공하는 버전들 중 가장 비슷한 버전인 2019.3.5 를 설치함

툴 박스에서 Maximun Heap Size 를 설정해줄 수 있는데, 인텔리제이에 메모리를 얼마나 할당할지 설정하는 것

16기가 램은 권장이 2048~4096 이므로 4096으로 설정함

 

2. 책을 따라서 프로젝트 생성하는 중

- 프로젝트 GroupId와 ArtifactId(프로젝트의 이름이 됨) 설정하는 부분에서

GroupId를 3단계(?) 로 설정하는 것이 보통이라고 했는데 그 이유가 뭔지 모르겠음

- 프로젝트 생성 디렉토리를 선택하는 부분이 실제로는 나오지 않았음

build.gradle 을 변경하여 그레이들 프로젝트를 스프링 부트 프로젝트로 변경하는 부분

- 책과 동일하게 설정

buildscript { ext { springBootVersion = '2.1.7.RELEASE' } repositories { mavenCentral() jcenter() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' group 'com.kcl.example' version '1.0-SNAPSHOT' sourceCompatibility = 1.8 repositories { mavenCentral() } dependencies { compile('org.springframework.boot:spring-boot-starter-web') testCompile group: 'junit', name: 'junit', version: '4.12' }

 

3. GitHub 연동하기

- 로그인이 안됨(404 Error)

- token 이용해서 로그인 했음

    깃헙에서 Settings - Developer settings - Personal access tokens - "Generate new token"

    여기서 Scopes 를 선택하게 되는데, 뭘 골라야 할지 몰라서 다 선택했음

- 인텔리제이의 plugins 에서 .ignore 를 설치해서 프로젝트 우클릭 - New - .ignore file - .gitignore file (Git) 으로 생성 화면 진입

    .idea (인텔리제이에서 자동으로 생성하는 파일, 프로젝트와는 관계 없음) 추가

- command + k : 깃 커밋 창

- command + shift + k : 깃 푸쉬 창

 

 

2020. 12. 30 수정

저자의 블로그에 변화된 부분에 대한 정리가 있다.

jojoldu.tistory.com/539

 

(2020.12.16) 스프링 부트와 AWS로 혼자 구현하는 웹 서비스 최신 코드로 변경하기

작년 11월 말에 스프링 부트와 AWS로 혼자 구현하는 웹 서비스를 출판 하였습니다. Spring Boot가 2.1 -> 2.4로, IntelliJ IDEA가 2019 -> 2020으로 오면서 너무 많은 변화가 있다보니, 집필할 때와 비교해 실습

jojoldu.tistory.com

참고해서 일단은 구버전으로 책을 따라 하고 버전업 된 것으로 또 해보자

 

 

2021. 01. 13 수정
git 연동이 안되었던 부분은
git update를 하니 해결이 되었다.
git 로그인이 잘 안될 때는 업데이트를 해보자.

 

 

 

 

chapter 8까지 구현하고 다시 복습하는 과정에서 인텔리제이 커뮤니티 버전을 계속 사용하기보다는 STS를 사용하는 편이 좋을 것 같아서 전환!

1. STS로 전환

Spring Tool Suite 4 (STS 4) 현재 21.01.17 기준 최신 버전인 4.9.0 버전 설치

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

 

 

2. 프로젝트 생성

Package Explorer 에서 우클릭 - New - Spring Starter Project

Name, Type, Java Version, Group 부분만 적당히 맞춰서 Next

 

이다음 부분은 어차피 변경할 거니까 Finish 해주자

 

3. 프로젝트 환경 변경

default 로 프로젝트를 생성하면 버전이 너무 최신이다.

책의 Github 레파지토리에 있는 README를  참고해서 환경을 일치시키자

github.com/jojoldu/freelec-springboot2-webservice

 

jojoldu/freelec-springboot2-webservice

Contribute to jojoldu/freelec-springboot2-webservice development by creating an account on GitHub.

github.com

 

 

... 잘 안됨..... 하는 중

-> 아래 build.gradle 에서 '-' 하나 빼먹었다고 안된 거였다. 너무해

 

4. 그레이들 프로젝트를 스프링 부트 프로젝트로 변경하기(?)

build.gradle 수정

buildscript {
	ext {	// 전역변수 설정
		springBootVersion = '2.1.7.RELEASE' 
	}
	repositories {		// 각종 의존성(리이브러리) 들을 어떤 원격 저장소에서 받을지?
		mavenCentral()	// 복잡, 예전부터 사용 
		jcenter()		// 간단
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
	}
}

// 여기 4개 plugin 은 자바와 스프링부트를 사용하기 위해서 항상 추가
apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'org.springframework.boot' 
apply plugin: 'io.spring.dependency-management'	// 스프링부트 의존성 관리

group = 'com.demo'
version = '1.0-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {	
	mavenCentral()	 
}

dependencies {	// 여기에서 버전을 명시하지 않아야 위에 buildscript-dependencies에서 설정한 버전을 따라감
	// 책에선 compile 로 되어있는데, implementation 으로 해도 상관은 없는 듯. compile 과 차이점을 정리
	implementation 'org.springframework.boot:spring-boot-starter'
	implementation 'org.springframework.boot:spring-boot-starter-web'
	testImplementation('org.springframework.boot:spring-boot-starter-test')
}

test {
	useJUnitPlatform()
}

 

 

- 기타

STS(이클립스) 의 Package Explorer 는 InteliJ 와 다르게 생겼다.

인텔리제이는 workspace가 없어서 프로젝트 하나밖에 안 보이는 반면 이클립스는 workspace에 존재하는 프로젝트가 전부 보인다.

보이는 구조? 도 다른데 이게 너무 어색하다.

인텔리제이와 비슷하게 맞춰주려면

아래 화살표를 눌러서 Package Presentation - Hierarchical 로 변경해주면

계층적으로 표현되어서 보기 좋다.

728x90
반응형