Spring mvc + mybatis web項目當系統啓動時自動調用某個方法

在這裏插入圖片描述
WebContextListener代碼:

package com.fantastic;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.ServletContext;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;
import org.springframework.web.context.ServletContextAware;

import com.alibaba.fastjson.JSONObject;
import com.fs.comm.mapper.SysParameterMapper;
import com.fs.comm.model.SysParameter;
import com.fs.web.service.SysParameterManagerService;

@Service
public class WebContextListener implements InitializingBean, ServletContextAware{
 
	@Resource
	private SysParameterMapper sysParameterMapper;
 
	@Resource
	private SysParameterManagerService sysParameterManagerService;
	
	@Override
	public void setServletContext(ServletContext servletContext) {
		try {
		//	myServer.bind(1235);
		//	System.out.println("開機啓動一次-----------------------");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
 
	@Override
	public void afterPropertiesSet() throws Exception {
		//開機後需要執行的業務邏輯
		
	}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章