==> com.exam의 서브패키지인 com.exam.service 에 있는 파일 => 자동 빈 생성
@Service
public class DeptServiceImpl implements DeptService {
@Autowired
DeptDAO dao;
}
@Service
public class DeptServiceImpl {
DeptDAO dao;
//기본생성자 제거 필수
//생성자 (@Autowired 필요 없음)
public DeptServiceImpl(DeptDAO dao) {
System.out.println("DeptServiceImpl 생성자로 자동 주입");
this.dao = dao;
}
main(){
ApplicationContext ctx = new GenerieXmlApplicationContext("dept.xml");
DeptService service = ctx.getBean("xxx", DeptService.class);
//Application에서 빈(DeptService) 사용
main(){
ApplicationContext ctx = SpringApplication.run(Application.class, args);
DeptService service = ctx.getBean("xxx", DeptService.class);