博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring mvc + mybatis web项目当系统启动时自动调用某个方法
阅读量:4182 次
发布时间:2019-05-26

本文共 823 字,大约阅读时间需要 2 分钟。

1、添加WebContextListener.java

2、文件内容

package com.pt.controller.listener;import javax.servlet.ServletContext;import org.springframework.beans.factory.InitializingBean;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.web.context.ServletContextAware;import com.pt.controller.netty.MyServer;@Servicepublic class WebContextListener implements InitializingBean, ServletContextAware{		@Autowired	private MyServer myServer;	@Override	public void setServletContext(ServletContext servletContext) {		try {			myServer.bind(1235);		} catch (Exception e) {			// TODO Auto-generated catch block			e.printStackTrace();		}			}	@Override	public void afterPropertiesSet() throws Exception {		// TODO Auto-generated method stub			}		 }

3、添加配置内容

4、最后启动tomcat。

你可能感兴趣的文章
被录取了!
查看>>
公司能不能监控到微信聊天?
查看>>
Pandas函数速查手册(高清版)PDF
查看>>
我终于有字节工牌了!!!哈哈哈哈哈哈哈哈哈哈
查看>>
上海有哪些牛逼的互联网公司?
查看>>
再见了,Teamviewer!
查看>>
Windows 11 上手体验!网友:果里果气的……
查看>>
上岸哈工大!
查看>>
Zigbee协议栈中文说明
查看>>
TinyXML2 学习
查看>>
onvif开发总结
查看>>
Web Service描述语言 WSDL 详解
查看>>
IP Camera 相关安装配置
查看>>
固定码率(CBR)与可变码率(VBR)
查看>>
jpg转bmp(使用libjpeg)
查看>>
bmp转jpg(使用libjpeg)
查看>>
gcc动态链接库基本知识
查看>>
gdb中忽略信号处理 SIGPIPE
查看>>
使用gdb调试网络程序时,收到SIGPIPE信号异常退出问题
查看>>
GDB+GdbServer: ARM程序调试
查看>>