热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

javaweb.xml中加载顺序

web.xml中加载顺序是context-param->listener->filter->servlet并不因在web.xml中配置顺序而改变以自己的项目tdsTest

web.xml中加载顺序是context-param -> listener -> filter -> servlet并不因在web.xml中配置顺序而改变


以自己的项目tdsTest为例
1.
首先读取web.xml中设置,根据 namecontextConfigLocation取相应的值,如

 classpath:application.xml

2.获取application.xml相应的设置,像这个project,就有import一个spring-mybatis.xml设置,然后初始化数据库相关配置

3. spring-mybatis.xml配置了数据库连接,mybatis印射的相关信息,从哪个地方去找mappermapper.xml,事务日志管理等

4.然后init DispatcherServlet,这里配置spring-mvc.xml servlet相关信息,比如自动扫描Controller,ServiceImpl,静态资源等

项目结构:

图片显示结构:



CallStack:

2017-07-19 19:11:30 [RMI TCP Connection(3)-127.0.0.1] INFO  org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
2017-07-19 19:11:30 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Wed Jul 19 19:11:30 CST 2017]; root of context hierarchy
2017-07-19 19:11:30 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [application.xml]
2017-07-19 19:11:30 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring/spring-mybatis.xml]
2017-07-19 19:11:30 [RMI TCP Connection(3)-127.0.0.1] INFO com.alibaba.druid.pool.DruidDataSource - {dataSource-1} inited
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 913 ms
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization started
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Jul 19 19:11:31 CST 2017]; parent: Root WebApplicationContext
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring/spring-mvc.xml]
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/info/getCatJobInfo],methods=[GET]}" onto public java.util.List com.ekin.test.controller.CatJobInfoController.getCatJobInfo()
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Jul 19 19:11:31 CST 2017]; parent: Root WebApplicationContext
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Jul 19 19:11:31 CST 2017]; parent: Root WebApplicationContext
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/common/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/css/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#1'
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/image/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#2'
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/js/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#3'
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/info/getCatJobInfo],methods=[GET]}" onto public java.util.List com.ekin.test.controller.CatJobInfoController.getCatJobInfo()
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Jul 19 19:11:31 CST 2017]; parent: Root WebApplicationContext
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization completed in 628 ms
2017-07-19 19:13:35 [http-apr-8080-exec-1] INFO com.ekin.test.controller.CatJobInfoController - [com.ekin.test.bean.CatJobInfo@1e7aff31, com.ekin.test.bean.CatJobInfo@1d07f999]



推荐阅读
  • 本文讨论了在Spring 3.1中,数据源未能自动连接到@Configuration类的错误原因,并提供了解决方法。作者发现了错误的原因,并在代码中手动定义了PersistenceAnnotationBeanPostProcessor。作者删除了该定义后,问题得到解决。此外,作者还指出了默认的PersistenceAnnotationBeanPostProcessor的注册方式,并提供了自定义该bean定义的方法。 ... [详细]
  • Spring特性实现接口多类的动态调用详解
    本文详细介绍了如何使用Spring特性实现接口多类的动态调用。通过对Spring IoC容器的基础类BeanFactory和ApplicationContext的介绍,以及getBeansOfType方法的应用,解决了在实际工作中遇到的接口及多个实现类的问题。同时,文章还提到了SPI使用的不便之处,并介绍了借助ApplicationContext实现需求的方法。阅读本文,你将了解到Spring特性的实现原理和实际应用方式。 ... [详细]
  • ZSI.generate.Wsdl2PythonError: unsupported local simpleType restriction ... [详细]
  • 在重复造轮子的情况下用ProxyServlet反向代理来减少工作量
    像不少公司内部不同团队都会自己研发自己工具产品,当各个产品逐渐成熟,到达了一定的发展瓶颈,同时每个产品都有着自己的入口,用户 ... [详细]
  • Spring学习(4):Spring管理对象之间的关联关系
    本文是关于Spring学习的第四篇文章,讲述了Spring框架中管理对象之间的关联关系。文章介绍了MessageService类和MessagePrinter类的实现,并解释了它们之间的关联关系。通过学习本文,读者可以了解Spring框架中对象之间的关联关系的概念和实现方式。 ... [详细]
  • Spring常用注解(绝对经典),全靠这份Java知识点PDF大全
    本文介绍了Spring常用注解和注入bean的注解,包括@Bean、@Autowired、@Inject等,同时提供了一个Java知识点PDF大全的资源链接。其中详细介绍了ColorFactoryBean的使用,以及@Autowired和@Inject的区别和用法。此外,还提到了@Required属性的配置和使用。 ... [详细]
  • SpringBoot整合SpringSecurity+JWT实现单点登录
    SpringBoot整合SpringSecurity+JWT实现单点登录,Go语言社区,Golang程序员人脉社 ... [详细]
  • 本文介绍了Java工具类库Hutool,该工具包封装了对文件、流、加密解密、转码、正则、线程、XML等JDK方法的封装,并提供了各种Util工具类。同时,还介绍了Hutool的组件,包括动态代理、布隆过滤、缓存、定时任务等功能。该工具包可以简化Java代码,提高开发效率。 ... [详细]
  • Firefox火狐浏览器关闭到http://detectportal.firefox.com的流量问题解决办法
    本文介绍了使用Firefox火狐浏览器时出现关闭到http://detectportal.firefox.com的流量问题,并提供了解决办法。问题的本质是因为火狐默认开启了Captive portal技术,当连接需要认证的WiFi时,火狐会跳出认证界面。通过修改about:config中的network.captive-portal-service.en的值为false,可以解决该问题。 ... [详细]
  • http:my.oschina.netleejun2005blog136820刚看到群里又有同学在说HTTP协议下的Get请求参数长度是有大小限制的,最大不能超过XX ... [详细]
  • 本文介绍了如何使用C#制作Java+Mysql+Tomcat环境安装程序,实现一键式安装。通过将JDK、Mysql、Tomcat三者制作成一个安装包,解决了客户在安装软件时的复杂配置和繁琐问题,便于管理软件版本和系统集成。具体步骤包括配置JDK环境变量和安装Mysql服务,其中使用了MySQL Server 5.5社区版和my.ini文件。安装方法为通过命令行将目录转到mysql的bin目录下,执行mysqld --install MySQL5命令。 ... [详细]
  • r2dbc配置多数据源
    R2dbc配置多数据源问题根据官网配置r2dbc连接mysql多数据源所遇到的问题pom配置可以参考官网,不过我这样配置会报错我并没有这样配置将以下内容添加到pom.xml文件d ... [详细]
  • Imtryingtofigureoutawaytogeneratetorrentfilesfromabucket,usingtheAWSSDKforGo.我正 ... [详细]
  • 网络请求模块选择——axios框架的基本使用和封装
    本文介绍了选择网络请求模块axios的原因,以及axios框架的基本使用和封装方法。包括发送并发请求的演示,全局配置的设置,创建axios实例的方法,拦截器的使用,以及如何封装和请求响应劫持等内容。 ... [详细]
  • 本文记录了在vue cli 3.x中移除console的一些采坑经验,通过使用uglifyjs-webpack-plugin插件,在vue.config.js中进行相关配置,包括设置minimizer、UglifyJsPlugin和compress等参数,最终成功移除了console。同时,还包括了一些可能出现的报错情况和解决方法。 ... [详细]
author-avatar
栋逼逼丶
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有