SSM整合_MQ(eclipse版本) 超详细Spring+SpringMVC+Mybatis整合

本文提供了SSM(Spring+SpringMVC+Mybatis)整合的详细步骤,包括创建Maven Web工程,搭建Spring、SpringMVC、Mybatis框架,以及整合过程和Log4j配置。通过一步步指导,最终完成SSM整合并进行测试,确保项目运行成功。
摘要由CSDN通过智能技术生成

SSM整合_MQ(eclipse版本)

超详细Spring+SpringMVC+Mybatis整合

0创建项目

1)、创建Maven的简单web工程 在这里插入图片描述
在这里插入图片描述

2)、补全WEB-INF目录和web.xml文件:
在这里插入图片描述

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>ssm_demo</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>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>

3)、创建包路径和目录
在这里插入图片描述
4)、在pom.xml文件中集中定义依赖版本号

<!-- 集中定义依赖版本号 -->
<properties>
	<junit.version>4.10</junit.version>
	<spring.version>4.1.3.RELEASE</spring.version>
	<mybatis.version>3.2.8</mybatis.version>
	<mybatis.spring.version>1.2.2</mybatis.spring.version>
	<mysql.version>8.0.12</mysql.version>
	<druid.version>1.1.6</druid.version>
	<slf4j.version>1.6.4</slf4j.version>
	<jstl.version>1.2</jstl.version>
	<servlet-api.version>2.5</servlet-api.version>
	<jsp-api.version>2.0</jsp-api.version>
	<jackson.version>2.4.2</jackson.version>
</properties>

<dependencies>
	<!-- 单元测试 -->
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>${
   junit.version}</version>
		<scope>test</scope>
	</dependency>		
</dependencies>

1 搭建spring框架

1)、在pom.xml文件中,引入spring的依赖包

<!-- 整合spring框架(包含springmvc)
	这个jar文件包含springmvc开发时的核心类, 同时也会将依赖的相关jar文件引入进来(spring的核心jar文件也包含在内)
 -->
<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-webmvc</artifactId>
	<version>${
   spring.version}</version>
</dependency>
<!--这个jar文件包含对Spring对JDBC数据访问进行封装的所有类 -->
<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-jdbc</artifactId>
	<version>${
   spring.version}</version>
</dependency>
<dependency>
	<groupId>org.springframework</groupId>
	<artifactId>spring-aspects</artifactId>
	<version>${
   spring.version}</version>
</dependency>

2)、在resources/spring目录下,创建spring的核心配置文件:applicationContext.xml
在这里插入图片描述
配置内容如下:

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
	http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">
</beans>

至此,spring框架搭建完成,可自行测试

2 搭建springMVC框架

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值