Skip to content

[24기_손주완] spring tutorial 미션 제출합니다. - #3

Open
Wannys26 wants to merge 4 commits into
CEOS-Developers:masterfrom
Wannys26:Wannys26
Open

[24기_손주완] spring tutorial 미션 제출합니다.#3
Wannys26 wants to merge 4 commits into
CEOS-Developers:masterfrom
Wannys26:Wannys26

Conversation

@Wannys26

@Wannys26 Wannys26 commented Sep 9, 2026

Copy link
Copy Markdown

No description provided.

@whc9999 whc9999 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

미션에서 요구한 Spring Tutorial 구현부터 여러 개념을 굉장히 꼼꼼하게 정리해주신 것 같습니다! 😊
특히 단순 정리에서 끝나지 않고 게시판 예제와 연결해서 설명한 점이 이해하기 좋았습니당

몇 가지 더 살펴보면 좋을 부분에 코멘트 남겼으니 참고해보시면 좋을 것 같습니다! 수고하셨습니다~~~

.andExpect(status().isOk())
.andExpect(result -> {
String response = result.getResponse().getContentAsString();
assert response.equals("Hello, Spring Boot!");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

java의 assert는 jvm 옵션에 따라 검증이 수행되지 않을 수도 있어서
andExpect(content().string("Hello, Spring Boot!"))나
AssertJ의 assertThat(response).isEqualTo(...)를 사용해보면 좋을 것 같아용


jpa:
hibernate:
ddl-auto: create

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이번 미션에서는 create가 맞지만, 실제 프로젝트에서는 앱 재시작 시 데이터가 사라질 수 있어 운영 환경에서 사용하면 위험하다는 점 알아주세용.

update나 validate 또는 Flyway같은 migration 도구에 대해 공부해보시면 좋을 것 같습니다!

Comment on lines +15 to +18
@Transactional(readOnly = true)
public List<Test> findAllTests() {
return testRepository.findAll();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

단순 조회 메서드에 읽기 전용 트랜잭션을 명시하고, REpository를 Service에서 감싼 구조가 깔끔하네요 👍🏿👍🏿

여기서 왜 Controller가 Repository를 바로 호출하지 않고 Service 계층을 두었을까요?

Comment thread README.md
Comment on lines +216 to +219
프록시 객체가 메서드 호출을 가로채서
메서드 실행 전 트랜잭션을 시작하고,
정상적으로 끝나면 커밋하며,
예외가 발생하면 롤백한다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Transacrional의 기본 rollback 정책도 같이 확인해보면 좋을 것 같습니당

기본적으로 모든 예외가 아니라 RuntimeException이나 Error에서 rollback 되고, checked exception은 별도의 설정이 필요합니다!

Comment on lines +18 to +20
public List<Test> findAllTests() {
return testService.findAllTests();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Test 엔티티를 Controller에서 바로 반환하고 있는데용,
이번 미션에서는 단순 엔티티라 괜찮지만, 실제 프로젝트에서는 Entity와 API Response DTO를 분리하는 이유도 함께 공부해보시면 좋을 것 같습니다!

@9dongs 9dongs left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

게시판 예제를 중심으로 개념을 일관되게 설명해주셔서 이해하기 좋았습니다!
Bean 생명주기와 요청 처리 순서에서 조금의 의견을 댓글로 남겼습니다.
참고해주시면 감사하겠습니다. 고생하셨습니다!

Comment thread README.md
요청 3 → 새로운 객체
```

Spring은 Prototype Bean의 생성과 의존성 주입까지 관리하지만,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Prototype이 Singleton과 생명주기 관리 범위가 다르다는 점을 짚어주신 것이 좋습니다!
이 내용에서 @PreDestroy 같은 소멸 콜백은 Spring이 자동으로 호출하지 않는다는 사실을 찾았습니다!
생성, 의존성 주입, 초기화까지만 Spring이 처리하고 이후 필요한 자원 정리는 사용하는 쪽에서 책임진다는 점을 이야기해주시면 더 좋을거 같아요!

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.

잘 읽어봐주셔서 감사합니다 동현님! 말씀해주신 부분은 더 적어두는게 맞을거 같네용 감사합니다!

@kkangmen

Copy link
Copy Markdown

IoC/DI, AOP, PSA 그리고 POJO까지 순수 Java로 구현한 코드와 스프링을 사용한 코드를 같이 비교해주셔서 훨씬 이해하기 편했습니다!
추가로 Spring AOP가 프록시 기반 동작이기에, 같은 클래스 내부에서 this.method() 형식으로 호출하면 자기 자신(원본)을 가르키기에 AOP가 적용되지 않을 수 있다는 것도 알게 되었어요!

Comment thread README.md

1. Tomcat이 HTTP 요청을 받는다.
2. Tomcat이 DispatcherServlet에 요청을 전달한다.
3. DispatcherServlet이 HandlerMapping을 통해

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

추가로 저는 3번과 4번 과정을 좀 더 세부적으로 공부해봤는데 참고하시면 좋을 것 같습니다!
3. HandlerMapping을 통해 요청 URL에 매핑된 컨트롤러를 조회한다.
4. 컨트롤러를 실행할 수 있는 HandlerAdapter를 조회한다.
5. 조회한 HandlerAdapter가 실제 컨트롤러를 실행한다.

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.

좋은 조언들 감사합니다!! 말씀해주신 부분들 꼭 공부해볼게용ㅎㅎ

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.

4 participants