springboot中Listener的配置方法

App启动类需配置注解

@ServletComponentScan

监听器上需要配置注解

@WebListener

Listener示例

package org.goldwind.common;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
* @author 葛楠 	E-mail:[email protected]
* @version 创建时间:2017年5月27日 下午4:06:17
* 类说明
*/
@WebListener
public class IndexListener implements ServletContextListener{

	@Override
	public void contextDestroyed(ServletContextEvent event) {
		
	}

	@Override
	public void contextInitialized(ServletContextEvent event) {
		
	}
	
}

猜你喜欢

转载自blog.csdn.net/gn1992/article/details/78421531