Skip to content

[4주차] @Bean 애노테이션 도입 및 Controller 빈 등록 - 정인철#108

Open
incheol789 wants to merge 7 commits into
Loopers-play-dev-lab:incheol789from
incheol789:round4
Open

[4주차] @Bean 애노테이션 도입 및 Controller 빈 등록 - 정인철#108
incheol789 wants to merge 7 commits into
Loopers-play-dev-lab:incheol789from
incheol789:round4

Conversation

@incheol789

Copy link
Copy Markdown
Collaborator

구현 내용

Bean 이름 기반 관리

  • ApplicationContext의 빈 저장소를 ListMap<String, Object>로 변경
  • 빈 이름 자동 생성 (클래스명 camelCase 변환)

@bean 애노테이션

  • @Bean 애노테이션 정의 (메서드 레벨, 이름 지정 가능)
  • registerBeanMethods()@Component 클래스 내 @Bean 메서드 스캔 후 빈 등록
  • 외부 라이브러리 클래스도 팩토리 메서드 방식으로 등록 가능

Controller 빈 등록

  • @RequestMapping 애노테이션 정의
  • LectureController@Component + @RequestMapping("/lectures") 적용
  • getControllerMapping() — 등록된 빈 중 Controller 타입만 URL과 자동 매핑
  • LectureApplication에서 수동 new LectureController() 제거

변경 전후

[Before]
ApplicationContext → List<Object>로 빈 관리 (이름 없음)
LectureApplication → new LectureController() 수동 생성 + 수동 URL 매핑

[After]
ApplicationContext → Map<String, Object>로 빈 관리 (이름 기반)
@Bean 메서드 → 외부 라이브러리 클래스도 빈 등록 가능
LectureApplication → ac.getControllerMapping()으로 자동 URL 매핑

체크리스트

  • ApplicationContext 빈 저장소 Map으로 변경
  • 빈 이름 자동 생성 (generateBeanName)
  • @Bean 애노테이션 추가
  • registerBeanMethods()@Bean 메서드 빈 등록
  • @RequestMapping 애노테이션 추가
  • LectureController 빈으로 등록
  • getControllerMapping()으로 URL 자동 매핑
  • LectureApplication 수동 매핑 코드 제거
  • 빌드 성공

jude-loopers and others added 7 commits April 12, 2026 23:32
…template-main

2주차 자바 웹 요청 추상화
- ApplicationContext: beans를 Map으로 변경하여 이름 기반 빈 관리
- @bean 애노테이션 추가 및 registerBeanMethods() 구현
- @RequestMapping 애노테이션 추가
- LectureController: @component, @RequestMapping("/lectures") 적용
- LectureApplication: 수동 컨트롤러 매핑 제거, getControllerMapping() 자동화
@incheol789 incheol789 self-assigned this May 13, 2026
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