package com.sf.di;


import com.sf.di.service.BookService;
import com.sf.di.service.TeacherService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

/**
 * @author WanJl
 * @version 1.0
 * @title Main
 * @description
 * @create 2025/11/30
 */
public class Main {
    public static void main(String[] args) {
        //1、根据类路径加载配置文件
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        //2、根据文件路径加载配置文件
        //ApplicationContext context =new FileSystemXmlApplicationContext("E:\\授课资料\\2025年授课资料\\就业班授课资料\\J250419\\授课代码\\springDemo\\src\\main\\resources\\applicationContext.xml");
        //TeacherService teacherService = (TeacherService)context.getBean("teacherService");
        //teacherService.servicePrint();
        //1、通过bean的id和name获取bean
        //BookService bookService = (BookService)context.getBean("bookService");
        //2、通过bean的id|name以及bean的所属类型获取bean
        //BookService bookService = context.getBean("bookService", BookService.class);
        //3、通过bean所属类型获取bean
        BookService bookService = context.getBean(BookService.class);
        bookService.queryAllBook();
    }
}
