如果在启动项目的时候做一些事情可以使用 ServletContextListener 监听器
编写类 实现接口 ServletContextListener 重写 public void contextInitialized(ServletContextEvent sce) {}方法即可;
在springboot中 在编写的类上使用注解 @WebListener 在启动类上使用 @ServletComponentScan 即可(注解不唯一);
ServletContextListener
最新推荐文章于 2020-02-13 16:41:19 发布