Skip to content

[21기_박서연] spring tutorial 미션 제출합니다. #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: SeoyeonPark1223
Choose a base branch
from

Conversation

SeoyeonPark1223
Copy link

No description provided.

Copy link

@challonsy challonsy left a comment

Choose a reason for hiding this comment

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

저는 그냥 java 디렉토리 아래에 컨트롤러, 서비스 모두 몰아 넣었는데 계층 별 폴더를 만들어서 작성하니까 보기에 더 깔끔하고 좋은 것 같습니다! 도메인을 기준으로 디렉터리를 만들어서 해당 폴더 안에 관련 컨트롤러, 서비스, 리포지토리를 몰아 넣는 방법도 좋다고 본 것 같은데 앞으로 배워나가면서 어떤 방법이 편한지 시험해봐야겠다는 생각이 듭니다 👍

Copy link

@choiseoji choiseoji left a comment

Choose a reason for hiding this comment

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

우와우와! 1주차 과제 정말 고생 많으셨습니다!
앞으로도 함께 파이팅해봐요! 💪🔥


- Spring에서 **어노테이션을 통해 빈을 자동 등록(Bean Registration)** 할 수 있음
1. Spring이 `@ComponentScan`을 실행하여 특정 패키지를 스캔
2. 해당 패키지 내에서 `@Component`, `@Service`, `@Repository`, `@Controller`가 붙은 클래스를 찾음

Choose a reason for hiding this comment

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

@ComponentScan@Component 어노테이션이 붙은 클래스를 스캔하여 빈으로 등록해주는 역할을 하는데,
@Service, @Repository, @Controller 어노테이션은 어떻게 @componentscan에 의해 스캔되어 빈으로 등록이 되는걸까요??
한번 저 3개 어노테이션의 구현부를 확인해봐도 좋을거 같습니다 😊

README.md Outdated
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import static org.hamcrest.core.IsEqual.equalTo;

@SpringBootTest

Choose a reason for hiding this comment

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

만약 @SpringBootTest 어노테이션을 사용하지 않는다면 어떻게 될까요?
해당 예제 코드에 사용된 어노테이션의 역할을 공부해보면 더 재밌을거 같아요!! 🙌

Choose a reason for hiding this comment

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

Q. 현재 작성한 테스트코드는 (단위테스트, 통합테스트) 중 어느 것에 속할까요?
+
만약 보다 빠르고 가벼운 Controller 테스트를 위해서 (@SpringBootTest, @AutoConfigureMockMvc) 대신에 @WebMvcTest를 사용했을 때의 차이는 무엇일지 생각해본다면 좋을 것 같습니다!


## 4. Spring Annotation 분석

### 어노테이션의 활용

Choose a reason for hiding this comment

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

혹시 사용자 정의 어노테이션을 만들 수 있다는 사실... 알고 계셨나요!!!?
저는 이전 프로젝트에서 로그인한 유저를 찾는 기능을 @Login 어노테이션으로 만들어서 사용했는데 참 편하고 좋더라구요~
이참에 커스텀 어노테이션을 만드는 방법도 한 번 공부해보시면 좋을 것 같아요! 👻


![PSA](./readme-src/psa.png)

- `DBClient`에서 어떤 `Connector` 객체에 접근하려해도 모두 같은 추상화된 interface를 거치고 `getConnection()`으로 접근 가능함

Choose a reason for hiding this comment

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

오오 이해가 너무 잘 됩니다 🙌


- **반복 사용되는 로직들을 모듈화 하여 필요할때 호출해서 사용하는 방법**

![AOP](./readme-src/aop.png)

Choose a reason for hiding this comment

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

저는 요즘 로깅에 AOP를 적용하는 방법을 고민 중이에요..! 🤔
AOP를 공부하는 김에, 로깅에 적용한 예시도 함께 살펴보면 더 재미있을 것 같아요!
요즘 많이들 로깅에 활용하는거 같더라구요!!

@WithFortuna
Copy link

우선 1주차 과제 수고하셨습니다!

Copy link

@WithFortuna WithFortuna left a comment

Choose a reason for hiding this comment

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

고생하셨습니다! 리드미에 올리신 사진 자료들이 진짜 좋은 것 같습니다 :)


### H2 Database

- reference: [reference doc](https://phantom.tistory.com/59)

Choose a reason for hiding this comment

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

참고한 레퍼런스 넣어주신게 좋네요!

README.md Outdated
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import static org.hamcrest.core.IsEqual.equalTo;

@SpringBootTest

Choose a reason for hiding this comment

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

Q. 현재 작성한 테스트코드는 (단위테스트, 통합테스트) 중 어느 것에 속할까요?
+
만약 보다 빠르고 가벼운 Controller 테스트를 위해서 (@SpringBootTest, @AutoConfigureMockMvc) 대신에 @WebMvcTest를 사용했을 때의 차이는 무엇일지 생각해본다면 좋을 것 같습니다!


![AOP](./readme-src/aop.png)

- Proxy 기반 AOP

Choose a reason for hiding this comment

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

관심사를 분리시키는 것이 목적인 AOP의 실제 적용방법을 찾으신게 좋네요 :)
조금만 더 구체적으로는 어떤게 있을지 찾아본다면 더욱 좋을 것 같습니다!
(제가 알고 있는 사례로는 @transactional이 있네요! 해당 어노테이션을 이용해서 트랜잭션을 시작하고 커밋/종료하는 기능을 별도의 Proxy객체가 원본객체보다 앞단에서 작동합니다)

README.md Outdated
### Bean Life Cycle

- Spring이 객체(Bean)의 생성과 소멸 및 생명주기를 관리
1. 스프링 IoC 컨테이너 생성

Choose a reason for hiding this comment

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

스프링 빈을 관리하는 주체를 명확히 컨테이너라고 파악하고 생명주기에도 표기해주신게 좋네요!

6. 소멸 전 콜백 메소드 호출
7. 스프링 종료

## 4. Spring Annotation 분석

Choose a reason for hiding this comment

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

스프링이 어노테이션을 어떻게 활용하는지 이해가 잘 되네요! :)
Q. 혹시 어노테이션이 종류에 따라서 컴파일 후에 사라지기도 한다는 사실... 알고계셨나요?
아래에 서지님이 작성하신 리뷰처럼 어노테이션의 구현부를 직접 학인해보면 알 수 있겠지만 @retention@target을 사용해서

  • 해당 어노테이션을 붙일 수 있는 위치
  • 어느 시점까지 살아있게(?) 할지 //ex)런타임까지 어노테이션 확인 가능 vs 컴파일 후에는 사라짐==런타임에 사용못함
    를 결정할 수도 있습니다!

Choose a reason for hiding this comment

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

오 이거 자료가 진짜 좋은 거 같아요. 덕분에 한번 더 공부하고 갑니다!

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