简易书籍管理系统(SSM框架整合+IDEA)

本文介绍了使用SSM(Spring+SpringMVC+MyBatis)框架整合搭建一个简易的书籍管理系统的过程,包括SSM框架的组件解释、项目创建步骤、配置文件编写、基本结构建立、运行效果展示以及可能出现的排错思路。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

书籍管理系统(SSM框架整合)


前言

用SSM框架实现的简易的书籍管理系统,能进行基本的CRUD功能。

一、SSM框架是什么?

1.SSM

SSM(Spring+SpringMVC+MyBatis)框架集由Spring、MyBatis两个开源框架整合而成(SpringMVC是Spring中的部分内容),常作为数据源较简单的web项目的框架。SSM框架是标准的MVC模式,将整个系统划分为DAO层,Controller层,Service层,View层四层,使用Spring MVC负责请求的转发和视图管理,Spring实现业务对象管理,Mybatis作为数据对象的持久化引擎。

2.Mybatis(持久层)

DAO层:DAO层主要是做数据持久层的工作,负责与数据库进行联络的一些任务都封装在此。

3.Spring(业务层)

Service层:Service层主要负责业务模块的逻辑应用设计。
Spring的核心思想是IoC(控制反转),即不再需要程序员去显式地new一个对象,而是让Spring框架帮你来完成这一切。

4.SpringMVC(表现层)

Controller层:Controller层负责具体的业务模块流程的控制。
SpringMVC在项目中拦截用户请求,它的核心Servlet即DispatcherServlet承担中介或是前台这样的职责,将用户请求通过HandlerMapping去匹配Controller,Controller就是具体对应请求所执行的操作,SpringMVC相当于SSH框架中struts。

5.View(视图层)

View层:View层与控制层结合比较紧密,需要二者结合起来协同工发。View层主要负责前台jsp页面的表示。


二、使用步骤

1. 建立Maven项目

  • 在IDEA的文件菜单选择new 新建项目,然后在左侧的任务栏里面找到Maven工程,本次工程名设为ssmbuild,填写好工程名称,点击完成即可

在这里插入图片描述
在这里插入图片描述

2. maven的安装

  1. 压缩包解压

  2. 配置环境变量
    我的电脑(此电脑)右键->属性->->高级系统设置->环境变量->系统变量Path把maven的bin路径粘贴到path里
    本机演示: [E:\办公\大三上\00实训\资料\apache-maven-3.6.3\bin]

    maven和jdk环境变量都要配置
    bin : 启动程序路径,也是环境变量主要的配置目录
    conf : maven核心配置文件

settings文件说明 localRepository :
maven本地库路径,注意如果仓库位置和已有文件一致则不需要修改文件,如果不一致则需要修改成目前的本地库路径
mirror :远程仓库路径

在这里插入图片描述

将m2本地仓库放在指定路径下,在下载的maven文件夹下conf—settings.xml文件

<localRepository>m2的安装路径</localRepository>

3. 控制命令测试Maven能否正常启动.

1.修改pom.xml文件

<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/maven-v4_0_0.xsd">
       <!-- 当前工程的信息说明-->
   	<modelVersion>4.0.0</modelVersion>
   	<groupId>org</groupId>
   	<artifactId>test</artifactId>
   	<packaging>jar</packaging>
   	<version>0.0.1-SNAPSHOT</version>
       <!-- 当前工程使用到的jar包-->
   	<dependencies>
   	   <dependency>
   		 <groupId>junit</groupId>
   		 <artifactId>junit</artifactId>
   		 <version>4.12</version>
   		 <scope>test</scope>
   	   </dependency>
   	</dependencies>	
   </project>

2.用在控制台中输入mvn compile,配置正确成功开始maven,错误可以出现在jdk版本,pom.xml文件等。
在这里插入图片描述
在这里插入图片描述

4.IDEA配置Maven

(注意每次建立新工程以后都需要重新配置IDEA里的Maven)
1.初始化,编写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>com.edu</groupId>
    <artifactId>ssmbuild</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>ssmbuild Maven Webapp</name>
    <!-- FIXME change it to the project's website -->
    <url>http://www.example.com</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>

    <dependencies>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <!--数据库驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.47</version>
        </dependency>
        <!-- 数据库连接池 -->
        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.5.2</version>
        </dependency>

        <!--Servlet - JSP -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!--Mybatis-->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.2</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>2.0.2</version>
        </dependency>

        <!--Spring-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.1.9.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>5.1.9.RELEASE</version>
        </dependency>
        <!--Lombok-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.10</version>
        </dependency>
    </dependencies>

    <build>
        <!--Maven资源过滤设置-->
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>


        <finalName>ssmbuild</finalName>
        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
            <plugins>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值