WebApplicationContext로 Bean 가져오기

WebApplicationContext로 Bean 가져오기

일하다 보니 옆에 동료가 물어보길래 궁금해서 찾아봄

  1. WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
  2. EgovIdGnrService egovService = (EgovIdGnrService)wac.getBean("egovPrforMncCertGnrService");
  3. System.out.println("ServletTest : " + egovService.getNextStringId());