package com.sf.beanLifeCycle;


import com.sf.beanLifeCycle.service.TeaService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author WanJl
 * @version 1.0
 * @title Main
 * @description
 * @create 2025/11/23
 */
public class Main {
    public static void main(String[] args) {
        //ApplicationContext接口没有close方法，所以要使用它的实现类
        ClassPathXmlApplicationContext context =
                new ClassPathXmlApplicationContext("applicationContext.xml");
        //注册销毁钩子方法，让Java程序在结束之前，先关闭IOC容器，再结束
        context.registerShutdownHook();

        TeaService teaService = (TeaService)context.getBean("TeaService");
        teaService.print();
        //程序结束之前，先销毁context
        //context.close();
    }
}
