JDK1.8+Spring5+SpringMVC5+Mybatis3.4项目(SMM框架)搭建

本文介绍了如何使用JDK1.8、Spring5、SpringMVC5和Mybatis3.4搭建项目,同时涉及Log4J2的配置。由于使用的是servlet2.5,因此需要在web.xml中配置Log4J2监听器。文章提供了web.xml、log4j2.xml、applicationContext.xml、spring-mvc.xml和spring-mybatis.xml等关键配置文件的详细内容,并展示了项目目录结构和控制器中使用Log4J2的日志记录方式。此外,还强调了aspectjweaver-1.8.10.jar在Spring事务配置中的重要性。
摘要由CSDN通过智能技术生成

版本情况:

spring5.0.4、SpringMVC5、Mybatis3.4、Log4J2、JDK1.8、servlet2.5

web.xml配置:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	id="WebApp_ID" version="2.5">
	<display-name>chinaTelecomLogAnalyzer</display-name>
	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
	
	<!-- spring配置文件路径 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:resource/applicationContext.xml</param-value>
	</context-param>
	
	<!-- Spring监听器 -->
	<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>
	
	<!-- log4j2配置 -->
	<context-param>
     <param-name>log4jConfiguration</param-name>
     <param-value>classpath:resource/log4j2.xml</param-value>
 </context-param>
	<listener>
    <listener-class>org.apache.logging.log4j.web.Log4jServletContextListener
    </listener-class>
	</listener>
	<filter>
		<filter-name>log4jServletFilter</filter-name>
	    <filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class>
    </filter>
	<filter-mapping>
	    <filter-name>log4jServletFilter</filter-name>
	    <url-pattern>/*</url-pattern>
	    <dispatcher>REQUEST</dispatcher>
	    <dispatcher>FORWARD</dispatcher>
	    <dispatcher>INCLUDE</dispatcher>
	    <dispatcher>ERROR</dispatcher>
	    <dispatcher>ASYNC</dispatcher> 
	</filter-mapping>
	
	
	
	<!-- 添加SpringMvc -->
	<servlet>
		<servlet-name>manager</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<description>springmvc</description>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:resource/spring-mvc.xml</param-value>
		</init-param>
		<load-on-startup>1&l
  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值