Skip to content

[그리디] 정명준 Spring Core(배포) 7~9단계 제출합니다. - #275

Open
htdufhc-bit wants to merge 101 commits into
next-step:htdufhc-bitfrom
htdufhc-bit:roomescape-core
Open

[그리디] 정명준 Spring Core(배포) 7~9단계 제출합니다.#275
htdufhc-bit wants to merge 101 commits into
next-step:htdufhc-bitfrom
htdufhc-bit:roomescape-core

Conversation

@htdufhc-bit

@htdufhc-bit htdufhc-bit commented Jul 27, 2026

Copy link
Copy Markdown

안녕하세요, 혜빈님! 그리디 4기 정명준입니다.
이번 마지막 Spring 배포 미션도 잘 부탁드립니다. 그리고 시간 내서 리뷰해주셔서 항상 감사합니다!!

🚗 단계별 설명

🚀 7단계 - @Configuration

  • JWT 관련 로직을 roomescape와 같은 계층의 auth 패키지의 클래스로 분리
  • 불필요한 DB 접근을 최소화

[반영 커밋] - 1ca564b

🚀 8단계 - Profile과 Resource

  • schema.sql 대신 데이터베이스를 초기화 해주기 위해 실행하는 클래스
  • token 생성에 필요한 비밀키값을 외부 파일로 분리

[반영 커밋] - bd048d0

🚀 9단계 - 배포 스크립트

  • ec2나 서버에서 배포를 할 수 있게 배포 스크립트를 작성

[반영 커밋] - 4076e21

💭 학습 내용

배포 스크립트 작성

초기 설정과 배포에 대한 스크립트를 setup.sh와 deploy.sh로 나누어 배포할 때마다 초기 설정을 반복하지 않도록 설계하였습니다. 스크립트 작성은 따로 학습 자료가 없어서 블로그와 AI를 참고해서 작성했습니다.

❓ 질문사항

Profile 사용 여부

이번 미션에서는 특수한 요구사항으로 인해 DataLoader를 구현하고, Profile을 통해 특정 환경에서만 적용되도록 구성했습니다.

다만 실제 운영 환경에서는 서버가 실행될 때마다 데이터를 다시 삽입할 일이 많지 않고, 잘못하면 중복 데이터가 생성될 수도 있기 때문에 DataLoader를 활용하는 경우는 많지 않을 것 같다는 생각이 들었습니다. 개발이나 테스트 환경에서 초기 데이터를 구성할 때는 유용하게 활용할 수 있을 것 같습니다.

혹시 혜빈님께서는 실제 프로젝트에서 Profile을 활용해 보신 경험이 있으신가요? 사용해 보셨다면 어떤 상황에서 활용하셨는지 궁금합니다!

🌱 원하는 피드백

이번 미션은 코드 구현보다는 개념을 이해하고 적용하는 데 초점이 맞춰져 있어, 크게 어려움을 느낀 부분이나 질문 사항은 없었습니다. 혜빈님이 남겨주시는 리뷰 내용으로 열심히 공부해보겠습니다!!
배포 스크립트는 아직 배포를 진행하지 못해, 실제로 작동되는지를 확인하지 못했습니다. 그래서 잘못된 부분이나 개선할 부분 있으면 말씀해주세요!!

…VC-auth

# Conflicts:
#	src/main/java/roomescape/config/WebConfig.java
#	src/main/java/roomescape/member/MemberRequest.java
#	src/main/java/roomescape/member/repository/MemberDao.java
#	src/main/java/roomescape/reservation/ReservationService.java
#	src/main/java/roomescape/reservation/controller/ReservationController.java
#	src/test/java/roomescape/MissionStepTest.java
@c0mpuTurtle

c0mpuTurtle commented Jul 29, 2026

Copy link
Copy Markdown

🌱<인사>

안녕하세요 명준님 :)

제 마지막 리뷰이가 되셨네요 ㅎㅎㅎ
벌써 스터디가 마지막이네요 ㅜㅠ 싱숭생숭합니다.

명준님은 어떠신가요?
저는 명준님을 보며 첫 스터디 때에 비해서 정말 많이 성장했다고 느끼는 데
명준님도 그렇게 느끼시나요? ㅎㅎㅎ
마지막 리뷰까지 화이팅입니다..!! 그동안 고생 많으셨어요 명준님! 🙌


❓<질문 사항>

실제 프로젝트에서 Profile을 활용해 보신 경험이 있으신가요? 사용해 보셨다면 어떤 상황에서 활용하셨는지 궁금합니다!

->
씁....사실 저도 아직 실무에서 Profile을 직접 활용해본 경험은 없습니다....하하
local/dev/prod 환경별로 DB 설정이나 yml 등을 분리할 때 쓰인다 정도만 알고 있습니다.

😃<전체적인 리뷰>

전체적으로 코드를 정말 깔끔하게 잘 짜주셨다고 생각합니다.
패키지 구조도 잘 정리되어 있어서 보기 편했어요.

다만 어노테이션을 조금 더 적극적으로 활용하시면 코드가 한층 더 간결해질 것 같습니다.
예를 들어 @Getter, @NoArgsConstructor 같은 Lombok 어노테이션들을 적재적소에 사용하시면 보일러플레이트 코드를 많이 줄일 수 있을 거예요!!

@builder에 대해서도 한 번 공부해보세요!
지금 명준님 코드에서는 쓰일만한 부분을 찾지 못 했는 데 앞으로 프로젝트 하실 때 많이 쓰실 겁니다 :)

Comment on lines 27 to 28
public RefreshToken() {
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NoArgsConstructor어노테이션에 대해 알아볼까요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lombok 라이브러리에서 제공하는 어노테이션으로, final 필드가 없을 때 파라미터가 없는 생성자를 만들어줍니다!

[반영 커밋] - 1be017e

Comment on lines 39 to 50

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Getter 어노테이션에 대해 알아볼까요?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lombok 라이브러리에서 제공하는 어노테이션으로, @Getter를 클래스에 붙이면 해당 클래스의 모든 필드에 대해 getter 메서드를 만들어줍니다.

[반영 커밋] - 1be017e / 6097143


Optional<RefreshToken> findByToken(String token);

Optional<RefreshToken> findByMemberId(Long memberId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안 쓰이는 메서드는 지워주는 게 좋을 거 같아요!!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

안 쓰이는 메서드들 지우는 법

안 쓰이는 메서드들은 지워주는 게 좋아요.
리팩터링이나 기능 수정 시 불필요한 분석 비용이 발생하고 코드의 가독성을 떨어뜨리기 때문입니다.!!
아래 꿀팁 하나 남기겠습니다~~

1. 단축 키 누르기

Window : Ctrl + Shift + Alt + I
Mac : Cmd + Option + Shift + I

2. Unused declaration 입력

Screenshot 2026-07-15 at 8 44 52 PM

3. 설정 버튼 누르기

Screenshot 2026-07-15 at 8 45 36 PM Screenshot 2026-07-15 at 8 45 42 PM

4. 아래와 같이 설정 후 [Rerun inspection] 누르기

Screenshot 2026-07-15 at 8 45 59 PM

5. 안 쓰이는 메서드 찾아 지우기 [Soft delete]

Screenshot 2026-07-15 at 8 46 57 PM

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 잘못 파악한 것일 수도 있지만, RefreshTokenRepository에 사용되지 않는 메서드가 하나 있어 제거했습니다.

[반영 커밋] - 79b95a4

Comment on lines +21 to +26
@Table(uniqueConstraints = {
@UniqueConstraint(
name = "uk_reservation_date_time_theme",
columnNames = {"date", "time_id", "theme_id"}
)
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 설정을 해준 이유가 무엇인가용?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

먼저 저번 스터디를 통해 서비스 계층에서만 예약 중복 여부를 검증하는 것으로는 부족하다는 것을 배웠습니다. 그래서 DB에도 unique 제약 조건이 필요하다고 판단했는데, date, time_id, theme_id에 각각 unique를 걸면 각 컬럼 값 자체가 중복될 수 없게 되어 의도와 달라집니다. 그래서 @UniqueConstraint로 세 컬럼을 묶어 복합 유니크 제약을 걸었습니다.

Comment thread setup.sh Outdated
Comment on lines +10 to +11
echo "[INFO] JDK 21 설치"
sudo apt install -y openjdk-21-jdk

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 명준님의 프로젝트는 java17을 쓰고 있는 데 java 21을 설치하고 있네요!
버전을 맞춰주는 게 좋을 거 같습니다!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니다!!

[반영 커밋] - 5471951

Comment thread setup.sh
Comment on lines +1 to +25
#!/bin/bash

REPOSITORY=/home/ubuntu/app
REPO_URL="https://github.com/htdufhc-bit/spring-basic-roomescape-playground"
PID_FILE="$REPOSITORY/app.pid"

echo "[INFO] 시스템 패키지 업데이트"
sudo apt update

echo "[INFO] JDK 21 설치"
sudo apt install -y openjdk-21-jdk

echo "[INFO] 프로젝트 디렉토리 생성 및 이동"
mkdir -p $REPOSITORY
cd $REPOSITORY

echo "[INFO] Git Repository 클론 또는 최신화"
if [ -d ".git" ]; then
echo "이미 git repository가 존재합니다. 최신 코드를 받아옵니다."
git pull
else
git clone $REPO_URL .
fi

echo "[INFO] 초기 설정 완료"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빌드 실패 시 어떻게 할 지도 다뤄주면 좋을 거 같아요.

또, 스크립트에 테스트를 포함하면 버그를 운영 환경이 아닌 배포 단계에서 잡을 수 있어요. :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deploy.sh 파일에 빌드를 하고, 실패했을 때 에러 로그를 띄우도록 수정했습니다!!

[반영 커밋] - d67fb2a

@htdufhc-bit htdufhc-bit left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 감사합니다, 혜빈님!!

자바 공부를 시작한 게 엊그제 같은데, 벌써 스터디가 끝난다는 게 믿기지 않네요...
스터디 덕분에 스프링도 열심히 공부하고 개발에 대해 이렇게 오래 고민해 본 것도 처음이라, 확실히 성장했다는 게 느껴집니다!!

Comment on lines 27 to 28
public RefreshToken() {
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lombok 라이브러리에서 제공하는 어노테이션으로, final 필드가 없을 때 파라미터가 없는 생성자를 만들어줍니다!

[반영 커밋] - 1be017e

Comment on lines 39 to 50

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lombok 라이브러리에서 제공하는 어노테이션으로, @Getter를 클래스에 붙이면 해당 클래스의 모든 필드에 대해 getter 메서드를 만들어줍니다.

[반영 커밋] - 1be017e / 6097143


Optional<RefreshToken> findByToken(String token);

Optional<RefreshToken> findByMemberId(Long memberId);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 잘못 파악한 것일 수도 있지만, RefreshTokenRepository에 사용되지 않는 메서드가 하나 있어 제거했습니다.

[반영 커밋] - 79b95a4

Comment thread setup.sh Outdated
Comment on lines +10 to +11
echo "[INFO] JDK 21 설치"
sudo apt install -y openjdk-21-jdk

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니다!!

[반영 커밋] - 5471951

Comment thread setup.sh
Comment on lines +1 to +25
#!/bin/bash

REPOSITORY=/home/ubuntu/app
REPO_URL="https://github.com/htdufhc-bit/spring-basic-roomescape-playground"
PID_FILE="$REPOSITORY/app.pid"

echo "[INFO] 시스템 패키지 업데이트"
sudo apt update

echo "[INFO] JDK 21 설치"
sudo apt install -y openjdk-21-jdk

echo "[INFO] 프로젝트 디렉토리 생성 및 이동"
mkdir -p $REPOSITORY
cd $REPOSITORY

echo "[INFO] Git Repository 클론 또는 최신화"
if [ -d ".git" ]; then
echo "이미 git repository가 존재합니다. 최신 코드를 받아옵니다."
git pull
else
git clone $REPO_URL .
fi

echo "[INFO] 초기 설정 완료"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deploy.sh 파일에 빌드를 하고, 실패했을 때 에러 로그를 띄우도록 수정했습니다!!

[반영 커밋] - d67fb2a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants