常有在spring容器启动后执行某些操作的需求,现做了一个demo的实现,做一下记录,也希望可以给需要的同学提供参考. 1.spring启动后,以新线程执行后续需要的操作,所以执行类实现Runnable接口 @Component public class StepExecutor implements Runnable{ @Overridepublic void run() {startStreamTask(); } public void startStreamTask() { //do yo
如下图所示,新建一个工作区间,添加tomcat之后通过ecliplse启动tomcat之后: 访问http://localhost:8080/出现404: 解决方法: 1.确保tomcat里面所有项目都remove掉了 2.双击服务器(就是下图) 然后按照下图修改: 如果上面需要编辑的页面还是灰色(无法编辑),那就把tomcat删掉,重新添加,然后编辑 Use tomcat installation(Task control of Tomcat installation) 即选择tomcat的安
Catalina的start方法 /** * Start a new server instance. */ public void start() { if (server == null) { load(); } long t1 = System.nanoTime(); // Start the new server if (server instanceof Lifecycle) { try { ((Lifecycle) server).start();//启动Server } catch
该系列文章是笔者在学习 Spring Boot 过程中总结下来的,里面涉及到相关源码,可能对读者不太友好,请结合我的源码注释 Spring Boot 源码分析 GitHub 地址 进行阅读 Spring Boot 版本:2.2.x 最好对 Spring 源码有一定的了解,可以先查看我的 <死磕 Spring 之 IoC 篇 - 文章导读> 系列文章 如果该篇内容对您有帮助,麻烦点击一下"推荐",也可以关注博主,感激不尽~ 该系列其他文章请查看:<精尽 Spring B