【Java】SSM框架整合 附源码

本教程详细介绍了如何在IDEA下整合Spring、Spring MVC和Mybatis(SSM)框架,包括添加依赖、创建数据库和数据表、编写实体类、Mapper接口和XML文件、配置各层以及Web.xml,最后进行测试。文中还提到了IDEA中处理XML文件不被编译的解决办法。
摘要由CSDN通过智能技术生成

前言

前面已经介绍Spring和Mybatis整合,而本篇介绍在IDEA下Spring、Spring MVC、Mybatis(SSM)三个框架的整合,在阅读本篇之前,建议大家先去了解一下Spring、Spring MVC、Mybatis(三大框架基础入门传送门),会达到事半功倍的效果。至于Spring MVC相对于Servlet、JSP的优点这里就不累赘了,大家可以上网查阅相关资料。本篇注重整合思路、整合过程以及整合过程中出现的坑。

项目目录

添加依赖包

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>ddnd</groupId>
    <artifactId>ddnd</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <!-- spring版本号 -->
        <spring.version>4.2.5.RELEASE</spring.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.4.6</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>1.3.2</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.13</version>
        </dependency>

        <!-- 添加spring核心依赖 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springf
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值