[study]이론정리/Spring Boot

생성된 빈 접근방법

yoon9i 2024. 7. 2. 15:32

8. 생성된 빈 접근하는 방법

  ApplicationContext ctx;

  public 생성자(ApplicationContext ctx) {
    this.ctx = ctx;
  }

  또는

  @Autowired
  ApplicationContext ctx;

  ctx.getBean("xxx", 클래스명.class); // @Service("xxx") public class DeptServiceImpl