三种Spring加载机制

时间:2023-03-09 13:27:33
三种Spring加载机制

方法一. 在main方法中启动Spring

ApplicationContext ac = new XmlApplicationContext("applicationContext.xml");

方法二. 利用Spring自带的Servlet启动, 配置好Servlet, 加载Servlet的时候, 就初始化了WebApplicationContext

方法三. 利用Spring自带的Listener启动, 装配好Listener, 加载Listener的时候, 就初始化了WebApplcaitionContext