[4주차] @Bean 애노테이션 도입 및 Controller 빈 등록 - 정인철#108
Open
incheol789 wants to merge 7 commits into
Open
Conversation
…template-main 2주차 자바 웹 요청 추상화
- ApplicationContext: beans를 Map으로 변경하여 이름 기반 빈 관리 - @bean 애노테이션 추가 및 registerBeanMethods() 구현 - @RequestMapping 애노테이션 추가 - LectureController: @component, @RequestMapping("/lectures") 적용 - LectureApplication: 수동 컨트롤러 매핑 제거, getControllerMapping() 자동화
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
구현 내용
Bean 이름 기반 관리
ApplicationContext의 빈 저장소를List→Map<String, Object>로 변경@bean 애노테이션
@Bean애노테이션 정의 (메서드 레벨, 이름 지정 가능)registerBeanMethods()—@Component클래스 내@Bean메서드 스캔 후 빈 등록Controller 빈 등록
@RequestMapping애노테이션 정의LectureController에@Component+@RequestMapping("/lectures")적용getControllerMapping()— 등록된 빈 중 Controller 타입만 URL과 자동 매핑LectureApplication에서 수동new LectureController()제거변경 전후
체크리스트
ApplicationContext빈 저장소Map으로 변경generateBeanName)@Bean애노테이션 추가registerBeanMethods()로@Bean메서드 빈 등록@RequestMapping애노테이션 추가LectureController빈으로 등록getControllerMapping()으로 URL 자동 매핑LectureApplication수동 매핑 코드 제거