SSM框架的整合—图书管理的增删改查

ssm+vue图书管理系统设计与实现 博主介绍:专注于Java(springboot ssm 等开发框架) vue .net php phython node.js uniapp 微信小程序 等诸多技术领域和毕业项目实战、企业信息化系统建设,从业十五余年开发设计教学工作☆☆☆ 精彩专栏推荐订阅☆☆☆☆☆不然下次找不到哟我的博客空间发布了1500+毕设题目 方便大家学习使用更多项目地址 介绍 翰文编程CSDN博客文末下方有源码获取地址。 阅读详情

系列文章目录

本节主要讲述SSM框架的整合技术和使用SSM开发的一个图书管理系统



前言

本节中用到的资料
链接:https://pan.baidu.com/s/1tSUMxH7G3-BX9MNnoVSw6Q?pwd=1111
提取码:1111


一.SSM整合

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

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

二、表现层数据封装

  • 前端接收数据格式一 创建结果模型类,封装数据到data属性中
  • 前端接收数据格式一封装操作结果到code属性中
  • 前端接收数据格式一封装特殊消息到message (msg)属性中

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

三、异常处理器

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

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

四、项目异常处理方案

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

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

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

五、案例:SSM整合标准开发

在这里插入图片描述

六、整体项目代码

1.前期准备

1.项目结构

在这里插入图片描述

在这里插入图片描述

2.所需的pom依赖

<?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>org.example</groupId>
    <artifactId>springmvc-08-ssm</artifactId>
    <version>1.0-SNAPSHOT</version>


    <packaging>war</packaging>

    <dependencies>
        <!--SpringMVC相关jar包-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.3.21</version>
        </dependency>
        <!--数据库连接池jar包-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.2.15</version>
        </dependency>
        <!--mybatis的jar包-->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.9</version>
        </dependency>
        <!--mysql的jar包-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.29</version>
        </dependency>
        <!--spring操作数据库的包-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>5.3.21</version>
        </dependency>
        <!--spring整合mybatis的包 -->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>2.0.7</version>
        </dependency>
        <!--junit的jar包-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>

        <!--spring整合Junit的jar包-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.3.21</version>
        </dependency>
        <!--Servlet相关jar包-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <!--JSON转化的jar包-->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.13.3</version>
        </dependency>
    </dependencies>
</project>

3.前端页面资料和SQL文件

在前言中有SQL文件和ssm相关的前端文件

2.配置类

1.JdbcConfig 配置数据源和添加事务管理

package org.example.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;

import javax.sql.DataSource;

public class JdbcConfig {

    @Value("${jdbc.driver}")
    private String drive;
    @Value("${jdbc.url}")
    private String url;
    @Value("${jdbc.username}")
    private String username;
    @Value("${jdbc.password}")
    private String password;


    @Bean
    public DataSource dataSource(){
        DruidDataSource ds=new DruidDataSource();
        ds.setDriverClassName(drive);
        ds.setUrl(url);
        ds.setUsername(username);
        ds.setPassword(password);
        return ds;
    }

    @Bean
    public PlatformTransactionManager transactionManager(DataSource dataSource){
        DataSourceTransactionManager dataSourceTransactionManager=new DataSourceTransactionManager();
        dataSourceTransactionManager.setDataSource(dataSource);
        return dataSourceTransactionManager;
    }
}

2.MybatisConfig 类 ——Mybatis相关配置

package org.example.config;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

public class MybatisConfig {
    //定义bean,SqlSessionFactoryBean,用于产生SqlSessionFactory对象
    @Bean
    public SqlSessionFactoryBean sqlSessionFactory(DataSource dataSource){
        SqlSessionFactoryBean ssfb=new SqlSessionFactoryBean();
        ssfb.setTypeAliasesPackage("org.example.domain");
        ssfb.setDataSource(dataSource);
        return ssfb;
    }

    //定义bean,返回MapperScannerConfigurer对象
    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer(){
        MapperScannerConfigurer msc=new MapperScannerConfigurer();
        msc.setBasePackage("org.example.dao");
        return msc;
    }
}

3.ServletConfig 类——Servlet相关配置

package org.example.config;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class ServletConfig extends AbstractAnnotationConfigDispatcherServletInitializer {
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{SpringConfig.class};
    }

    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{SpringMvcConfig.class};
    }

    protected String[] getServletMappings() {
        return new String[]{"/"};
    }
}

4.SpringConfig 类——Spring相关配置

package org.example.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@ComponentScan("org.example.service")
@PropertySource("classpath:jdbc.properties")
@Import({MybatisConfig.class,JdbcConfig.class})
@EnableTransactionManagement
public class SpringConfig {
}

5.SpringMvcConfig 类——SpringMVC相关配置

package org.example.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;

@Configuration
@ComponentScan({"org.example.controller","org.example.config"})
@EnableWebMvc
public class SpringMvcConfig {
}

6.SpringMvcSupport 类——释放所有静态资源

package org.example.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class SpringMvcSupport extends WebMvcConfigurationSupport {
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/pages/**").addResourceLocations("/pages/");
        registry.addResourceHandler("/js/**").addResourceLocations("/js/");
        registry.addResourceHandler("/css/**").addResourceLocations("/css/");
        registry.addResourceHandler("/plugins/**").addResourceLocations("/plugins/");
    }
}

3.数据层

1.Mapper接口代理文件

package org.example.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.domain.Book;

import java.util.List;

public interface BookDao {

    @Insert("insert into tbl_book(type,name,description) values(#{type},#{name},#{description})")
    int save(Book book);

    @Update("update tbl_book set type=#{type},name=#{name},description=#{description} where id =#{id}")
    int update(Book book);

    @Delete("delete from tbl_book where id = #{id}")
    int delete(Integer id);

    @Select("select * from tbl_book where id = #{id}")
    Book getById(Integer id);

    @Select("select * from tbl_book")
    List<Book> getAll();
}

2.实体类

package org.example.domain;

public class Book {
    private int id;
    private String type;
    private String name;
    private String description;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public String toString() {
        return "Book{" +
                "id=" + id +
                ", type='" + type + '\'' +
                ", name='" + name + '\'' +
                ", description='" + description + '\'' +
                '}';
    }
}

4.业务层

1.接口类

package org.example.service;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.domain.Book;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
public interface BookService {
    /**
     * 新增数据
     * @param book
     */
    boolean save(Book book);

    /**
     * 修改数据
     * @param book
     */
    boolean update(Book book);

    /**
     * 根据id删除数据
     * @param id
     */
    boolean delete(Integer id);

    /**
     * 根据id查询数据
     * @param id
     * @return
     */
    Book getById(Integer id);

    /**
     * 查询所有数据
     * @return
     */
    List<Book> getAll();
}

2.接口实现类

package org.example.service.impl;

import org.example.controller.Code;
import org.example.dao.BookDao;
import org.example.domain.Book;
import org.example.exception.BusinessException;
import org.example.exception.SystemException;
import org.example.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookDao bookDao;

    public boolean save(Book book) {
        return bookDao.save(book) > 0;
    }

    public boolean update(Book book) {
        return bookDao.update(book) > 0;
    }

    public boolean delete(Integer id) {
        return bookDao.delete(id) > 0;
    }

    public Book getById(Integer id) {
        if (id < 0) {
            throw new BusinessException(Code.PROJECT_BUSINESS_ERR, "请勿违法操作");
        }


        return bookDao.getById(id);
    }

    public List<Book> getAll() {
        return bookDao.getAll();
    }
}

5.控制层

1.业务处理类

package org.example.controller;

import org.apache.ibatis.annotations.Delete;
import org.example.domain.Book;
import org.example.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/books")
public class BookController {
    @Autowired
    private BookService bookService;

    @PostMapping
    public Result save(@RequestBody Book book) {
        boolean flag = bookService.save(book);
        return new Result(flag ? Code.SAVE_OK : Code.SAVE_ERR, flag);
    }

    @PutMapping
    public Result update(@RequestBody Book book) {
        boolean flag = bookService.update(book);
        return new Result(flag ? Code.UPDATE_OK : Code.UPDATE_ERR, flag);
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        boolean flag = bookService.delete(id);
        return new Result(flag ? Code.DELETE_OK : Code.DELETE_ERR, flag);
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id) {
        Book book = bookService.getById(id);
        Integer code = book != null ? Code.GET_OK : Code.GET_ERR;
        String msg = book != null ? "" : "数据查询失败,请重试";
        return new Result(code, book, msg);
    }

    @GetMapping
    public Result getAll() {

        List<Book> books = bookService.getAll();
        Integer code = books != null ? Code.GET_OK : Code.GET_ERR;
        String msg = books != null ? "" : "数据查询失败,请重试";
        return new Result(code, books, msg);

    }
}

2.前后端数据交换规范类

package org.example.controller;

public class Result {
    private Object data;
    private Integer code;
    private String msg;

    public Result() {
    }

    public Result(Integer code,Object data) {
        this.data = data;
        this.code = code;
    }

    public Result( Integer code, Object data,String msg) {
        this.data = data;
        this.code = code;
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String toString() {
        return "Result{" +
                "data=" + data +
                ", code=" + code +
                ", msg='" + msg + '\'' +
                '}';
    }
}

3.具体编码类

package org.example.controller;

public class Code {
    public static final Integer SAVE_OK=20011;
    public static final Integer DELETE_OK=20021;
    public static final Integer UPDATE_OK=20031;
    public static final Integer GET_OK=20041;


    public static final Integer SAVE_ERR=20010;
    public static final Integer DELETE_ERR=20020;
    public static final Integer UPDATE_ERR=20030;
    public static final Integer GET_ERR=20040;

    public static final Integer SYSTEM_UNKNOW_ERR=50001;
    public static final Integer SYSTEM_TIMEOUT_ERR=50002;
    public static final Integer PROJECT_VALIDATE_ERR=60001;
    public static final Integer PROJECT_BUSINESS_ERR=60002;
}

4.异常处理类(统一在表现层处理)

package org.example.controller;


import org.example.exception.BusinessException;
import org.example.exception.SystemException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//异常拦截器
@RestControllerAdvice
public class ProjectExceptionAdvice {

    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException e){
        return new Result(e.getCode(),null,e.getMessage());
    }

    @ExceptionHandler(SystemException.class)
    public Result doSystemException(SystemException e){
        //记录日志(错误堆栈)
        //发送邮件给开发人员
        //发送短信给运维人员
        return new Result(e.getCode(),null,e.getMessage());
    }

    //定义处理是哪种异常
    @ExceptionHandler(Exception.class)
    public Result doException(Exception e){
        //记录日志(错误堆栈)
        //发送邮件给开发人员
        //发送短信给运维人员
        return new Result(Code.SYSTEM_UNKNOW_ERR,null,"系统繁忙,请联系管理员");
    }
}

6.自定义异常类

1.业务处理异常类(自定义)

package org.example.exception;

public class BusinessException extends RuntimeException{
    private Integer code;


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(Integer code,String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }
}

2.系统异常类(自定义)

package org.example.exception;

public class SystemException extends RuntimeException{
    private Integer code;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public SystemException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public SystemException(Integer code,String message, Throwable cause) {
        super(message, cause);
        this.code = code;
    }


}

7.前端页面

<!DOCTYPE html>

<html>

<head>

    <!-- 页面meta -->

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <title>SpringMVC案例</title>

    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">

    <!-- 引入样式 -->

    <link rel="stylesheet" href="../plugins/elementui/index.css">

    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">

    <link rel="stylesheet" href="../css/style.css">

</head>

<body class="hold-transition">

<div id="app">

    <div class="content-header">

        <h1>图书管理</h1>

    </div>

    <div class="app-container">

        <div class="box">

            <div class="filter-container">

                <el-input placeholder="图书名称" v-model="pagination.queryString" style="width: 200px;"
                          class="filter-item"></el-input>

                <el-button @click="getAll()" class="dalfBut">查询</el-button>

                <el-button type="primary" class="butT" @click="handleCreate()">新建</el-button>

            </div>

            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>

                <el-table-column type="index" align="center" label="序号"></el-table-column>

                <el-table-column prop="type" label="图书类别" align="center"></el-table-column>

                <el-table-column prop="name" label="图书名称" align="center"></el-table-column>

                <el-table-column prop="description" label="描述" align="center"></el-table-column>

                <el-table-column label="操作" align="center">

                    <template slot-scope="scope">

                        <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>

                        <el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>

                    </template>

                </el-table-column>

            </el-table>

            <!-- 新增标签弹层 -->

            <div class="add-form">

                <el-dialog title="新增图书" :visible.sync="dialogFormVisible">

                    <el-form ref="dataAddForm" :model="formData" :rules="rules" label-position="right"
                             label-width="100px">

                        <el-row>

                            <el-col :span="12">

                                <el-form-item label="图书类别" prop="type">

                                    <el-input v-model="formData.type"/>

                                </el-form-item>

                            </el-col>

                            <el-col :span="12">

                                <el-form-item label="图书名称" prop="name">

                                    <el-input v-model="formData.name"/>

                                </el-form-item>

                            </el-col>

                        </el-row>


                        <el-row>

                            <el-col :span="24">

                                <el-form-item label="描述">

                                    <el-input v-model="formData.description" type="textarea"></el-input>

                                </el-form-item>

                            </el-col>

                        </el-row>

                    </el-form>

                    <div slot="footer" class="dialog-footer">

                        <el-button @click="dialogFormVisible = false">取消</el-button>

                        <el-button type="primary" @click="handleAdd()">确定</el-button>

                    </div>

                </el-dialog>

            </div>

            <!-- 编辑标签弹层 -->

            <div class="add-form">

                <el-dialog title="编辑检查项" :visible.sync="dialogFormVisible4Edit">

                    <el-form ref="dataEditForm" :model="formData" :rules="rules" label-position="right"
                             label-width="100px">

                        <el-row>

                            <el-col :span="12">

                                <el-form-item label="图书类别" prop="type">

                                    <el-input v-model="formData.type"/>

                                </el-form-item>

                            </el-col>

                            <el-col :span="12">

                                <el-form-item label="图书名称" prop="name">

                                    <el-input v-model="formData.name"/>

                                </el-form-item>

                            </el-col>

                        </el-row>

                        <el-row>

                            <el-col :span="24">

                                <el-form-item label="描述">

                                    <el-input v-model="formData.description" type="textarea"></el-input>

                                </el-form-item>

                            </el-col>

                        </el-row>

                    </el-form>

                    <div slot="footer" class="dialog-footer">

                        <el-button @click="dialogFormVisible4Edit = false">取消</el-button>

                        <el-button type="primary" @click="handleEdit()">确定</el-button>

                    </div>

                </el-dialog>

            </div>

        </div>

    </div>

</div>

</body>

<!-- 引入组件库 -->

<script src="../js/vue.js"></script>

<script src="../plugins/elementui/index.js"></script>

<script type="text/javascript" src="../js/jquery.min.js"></script>

<script src="../js/axios-0.18.0.js"></script>

<script>
    var vue = new Vue({

        el: '#app',
        data: {
            pagination: {},
            dataList: [],//当前页要展示的列表数据
            formData: {},//表单数据
            dialogFormVisible: false,//控制表单是否可见
            dialogFormVisible4Edit: false,//编辑表单是否可见
            rules: {//校验规则
                type: [{required: true, message: '图书类别为必填项', trigger: 'blur'}],
                name: [{required: true, message: '图书名称为必填项', trigger: 'blur'}]
            }
        },

        //钩子函数,VUE对象初始化完成后自动执行
        created() {
            this.getAll();
        },

        methods: {
            //列表
            getAll() {
                axios.get("/books").then((res) => {
                    this.dataList = res.data.data;
                })
            },

            //弹出添加窗口
            handleCreate() {
                this.dialogFormVisible = true;
                this.formData = {}
            },

            //重置表单
            resetForm() {
                this.formData = {}
            },

            //添加
            handleAdd() {
                axios.post("/books", this.formData).then((res) => {
                    console.log(res.data);

                    if (res.data.code == 20011) {
                        this.dialogFormVisible = false;
                        this.$message.success("添加成功");
                    } else if (res.data.code == 20010) {
                        this.dialogFormVisible = false;
                        this.$message.error("添加失败");
                    } else {
                        this.$message.error(res.data.msg);
                    }

                }).finally(() => {
                    this.getAll();
                })
            },

            //弹出编辑窗口
            handleUpdate(row) {
                console.log(row);
                //根据id查询数据
                axios.get("/books/" + row.id).then((res) => {
                    if (res.data.code == 20041) {
                        this.formData = res.data.data;
                        this.dialogFormVisible4Edit = true;
                    } else {
                        this.$message.error(res.data.msg);
                    }
                })
                //展示弹层
            },

            //编辑
            handleEdit() {
                axios.put("/books", this.formData).then((res) => {
                    console.log(res.data);

                    if (res.data.code == 20031) {
                        this.dialogFormVisible4Edit = false;
                        this.$message.success("修改成功");
                    } else if (res.data.code == 20030) {
                        this.dialogFormVisible4Edit = false;
                        this.$message.error("修改失败");
                    } else {
                        this.$message.error(res.data.msg);
                    }

                }).finally(() => {
                    this.getAll();
                })
            },

            // 删除
            handleDelete(row) {
                //1.弹出提示框
                this.$confirm("此操作永久删除当前数据,是否继续?", "提示:", {
                    type: 'info'
                }).then(() => {
                    //2.做删除业务
                    axios.delete("/books/" + row.id).then((res) => {
                        if (res.data.code == 20021) {
                            this.$message.success("删除成功");
                        } else {
                            this.$message.error("删除失败");
                        }
                    }).finally(() => {
                        this.getAll();
                    })
                }).catch(() => {
                    //3.取消删除
                    this.$message.info("取消删除操作");
                })
            }
        }
    })

</script>

</html>

其余在资料中即可查找

8.业务层端口单元测试类

package org.example.service;

import org.example.config.SpringConfig;
import org.example.domain.Book;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = SpringConfig.class)
public class BookServiceTest {
    @Autowired
    private BookService bookService;

    @Test
    public void testGetById(){
        Book book = bookService.getById(1);
        System.out.println(book);
    }

    @Test
    public void testGetAll(){
        List<Book> all = bookService.getAll();
        System.out.println(all);
    }
}


总结

参考视频

项目地址(完整项目已打包)
码云地址
CSDN地址

Zemax:初学者的混合模式 光线以序列模式开始,然后接近非序列组件的入口端口。到达入口端口后,光线以非序列模式传播,然后接近出口端口。光线离开出口端口后,我们又回到序列模式。在此博客中,使用混合模式的示例将演示根据您自己的需要复制此工作流程所需的基本设置,以及一些有用的技巧。非序列组件表面类型必须在序列模式和非序列模式下定义。为了定义非序列组件的几何形状,请转到设置->编辑器->非序列,单击非序列编辑器。一旦我们进入非序列组件编辑器:表面 2 上的组件组,找到一个对象类型并进行定义。它能让您兼具序列模式的精确性和非序列模式的灵活性。 阅读详情

相关推荐

基于STM32开发的智能语音控制系统

本文将介绍如何使用STM32微控制器开发一个智能语音控制系统,通过语音识别模块、OLED显示屏、Wi-Fi模块等实现对家用电器或其他设备的语音控制。智能语音控制系统的核心是STM32微控制器,通过语音识别模块识别用户的语音指令,并根据指令控制家用电器或其他设备。:定期测试语音识别模块、继电器控制模块、OLED显示屏和Wi-Fi模块的工作状态,确保系统能够在各种情况下正常运行,并保持智能语音控制系统的可靠性。本系统同样适用于办公环境,可以通过语音指令控制办公室设备,如照明、空调等,提供智能化的办公体验。

stm32d1219的博客 6921

基于SSM图书管理系统2

1,项目功能:1)用户管理用户包括为用户分配账号,修改密码,用户安全退出功能。此模块只能由系统管理员统一配置,用户不能自行注册,用户密码要进行加密处理。支持excel读者数据的导入。2)图书管理对需要图书进行增删改查操作,要提供完善的检索功能,以便于读者使用该系统进行图书检索,支持excel图书数据导入。3)借还管理每位读者要先交纳100元押金。每位读者最多可以同时借阅2本图书。读者借书后,若在30天内没有看完,则可以续借一次,续借之后若超出30天则进行扣款处罚。每延迟一天扣款1元钱。读者归还图书后,要进行天数清零。图书的借阅状态分为3种,分别是:已借出、已入库、延迟。4)系统管理本系统角色共分为3种:系统管理员、图书馆管理员、读者。由于各个角色的使用功能不一样,所以要加入权限控制使不同的角色登陆系统后所拥有的权限不同。5)出版社管理对出版社进行维护,便于在录入图书信息时进行快速选择。6)系统监控记录登陆用户的登陆时间、推出时间及在系统内进行的所有操作。7)数据分析提供图书种类的数据分析。      适合做毕业设计参考项目。2,涉及技术:SSM框架,Tomcat3,开发环境:IDEA,MySQL数据库4,讲解方式:从环境安装,项目搭建,以及项目介绍等进行讲解5,包含资料:项目源码(含数据库文件),环境安装包,项目文档。

VMware桥接模式实战:用手机热点给Linux虚拟机共享网络(附WiFi适配技巧)

本文详细介绍了在移动办公场景下,如何为VMware中的Linux虚拟机配置桥接模式,以通过手机热点共享网络。文章深入解析了桥接模式在无线环境下的工作原理,提供了从主机端准备、VMware设置到Linux虚拟机内部配置的完整实战步骤,并针对手机热点的特殊性,分享了MTU优化、DNS配置及常见网络问题的诊断与解决方案,帮助用户实现稳定高效的移动虚拟化办公。

2y3u4i5o6p的博客 1220

【SSM】整合(基于图书的增删改查操作)

如何整合Spring、SpringMVC、Mybatis?这篇文字通过简单的图书增删改查操作讲解SSM整合。

你不来,再美的天地,都狼藉 ~ 1051

MySQL根据idb文件恢复数据

恢复前提 MySQL 5.* 和 8.* 的恢复方式大同小异,最基本的区别是8.* 中,不再有表结构frm文件,所以要恢复 8.* 的数据,就必须要有完整的建表语句。 而恢复 5.* 的数据,就需要idb文件和 frm文件,当然,如果有完整的建表语句的话,不用frm文件也行。 恢复步骤 需要注意的是,以下操作需要选定数据库后执行。 5.* 恢复表结构 确定表列数 首先创建一张 与需要恢复数据的表 的名字相同的新表,如果已知原表的字段数量的话,就按照原表字段数建表,字段名和类型都不用考虑,如果不知道数量的话,

weixin_45121446的博客 5455

SPI模式下的SD卡读写,为什么你的数据总出错?详解时序与状态机避坑指南

本文深入探讨SPI模式下SD卡读写数据出错的根本原因,提供时序优化与状态机设计的实战指南。针对时钟周期计数、状态机跳转和忙检测等核心问题,详解命令时序细节、状态机同步策略及高级避坑技巧,帮助开发者提升SD卡在SPI模式下的稳定性和性能。

weixin_30514745的博客 267

SpringMVC-08-整合SSM之CRUD

查询书籍功能 完善Controller:BookController @Controller @RequestMapping("/book") public class BookController { //coontroller层调service层 @Autowired @Qualifier("BookServiceImpl") private BookService bookService; //查询全部的书籍,并且返回到书籍展示也命啊 @Req.

HUBA_yosa的博客 457

基于smart_rtmp直播,最简单的部署手册

版本号 添加内容 修改时间 V1.0 新建 2021年12月30日 V1.1 增加网页播放 2021年12月31日 V1.2 增加是否可以多流和测试数据 2022年1月5日 目录 一、软件储备 1.推流软件:OBS 2.服务器流媒体软件:smart_rtmp 3.播放软件:Pot...

qq_28768477的博客 1万+

构建SSM框架项目(图书的增删改查)

学完SSM(Spring,Spring MVC,MyBatis)框架,可以搭建一个简单小型的网页。 整合SSM框架基本思路: 新建数据库数据,里面包括我们需要用到book的相关信息 新建maven项目,里面添加web项目支持,且在pom.xml导入相关包,添加资源过滤配置。 web.xml中注册DispatcharServlet用于拦截请求至spring的资源文件(applicationContext.xml),以及注册编码过滤器(encodingFilter) 建立基本项目结构,pojo、dao

m0_51666430的博客 625

YOLOv13教程:手把手教你CSP_MutilScaleEdgeInformationSelect模块 通过DSM 在空间与局部对比域上做自适应选择

绿色线条为添加CSP_MutilScaleEdgeInformationSelect后的训练效果,map50指标提升12.45,准确率提升5.44。

FJN110的博客 823

Open3D 合并两个点云【2025最新版】

两个点云中的数据连接,博客长期更新,本文最新更新时间为:2025年4月26日。

点云侠的博客 7441

SSM练手小项目(实现书籍的增删改查。附带详细的源代码和注释。本篇是XML版ssm框架开发,注解版转至主页查看其他文章)

SSM练手小项目(实现书籍的增删改查。附带详细的源代码和注释。本篇是XML版ssm框架开发,注解版转至主页查看其他文章)

weixin_46009389的博客 401

用AList挂载网盘,无损看VR电影教程,无需下载到PICO头显本地!

用AList挂载网盘 + WebDAV直连头显,看片像拉本地一样流畅,不怕卡顿、不怕没空间,简直是VR看片刚需配置!别再用U盘传电影了,用AList + WebDAV,直接流畅看4K,看片效率翻倍,体验提升一个档次!

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 5585

SSM框架整合——增删改查图书管理系统

1、创建数据库、表、插入对应的数据 2、

weixin_45082647的博客 3899

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

ssm框架整合完整版

一、引言 通过建立一个简单的图书管理系统,来对ssm框架进行整合,理解其具体的原理。本实验从最基本的数据库见表到最后实现前端的增删改查,附有详细的步骤,对一些细节做了描述。 环境要求: IDEA MySQL 5.7.19 Tomcat 8 Maven 3.6 二、创建数据库 1、创建数据库之前记得登陆数据库,打开cmd,输入 mysql -h localhost -P3306 -u root -p 也可以手动打开,前提是下载安装好了mysql!!! 2.下载SQLyog,登陆进去,创建数据库并建立新

qq_39176095的博客 1719

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

JavaEE SSM框架整合 图书管理系统 实战D2 实现增删改查

SSM 图书管理 增删查改 登录 注册

m0_64594973的博客 2785

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

SpringMVC:整合SSM(图书管理系统的增删改查)

文章目录SpringMVC:整合SSM(一)环境配置(二)数据库准备(三)项目环境搭建1.创建一个maven项目,添加WEB框架支持2.导入相关pom依赖3.Maven资源过滤设置4.构建基本结构、配置框架(三)编写MyBatis层 SpringMVC:整合SSM (一)环境配置 IntelliJ IDEA Maven 3.6 Tomcat 9 MySQL 5.7.19 (二)数据库准备 创建...

Pluto.的博客 3102

SSM小项目看图整合,保证能几分钟从无到有搭建出来

我自己的一个图书管理系统小项目,整合了SSM框架,功能简单,只有简单的增删改查,但是框架是完整的,亲测能跑的。 我先贴了项目架构图,先把所有文件都创建出来,然后我还把项目中所有代码都分类贴在下面的了。 先按照架构图创建出所有文件,然后按照下面前端、java、xml的分类,把各个文件的代码依次复制进去,几分钟就能搭建出来一个完整的SSM框架。 先上结构图: 前端结构: 代码结构: xml结构: 一、先照着结构图把所有文件都创建出来,我下面直接粘贴上所有文件的代码 二、前端代码部分: addBook.js

weixin_43923436的博客 199

SpringMVC学习:整合SSM框架

整合SSM框架,实现图书管理功能。

weixin_51624761的博客 1313

第一次整合SSM框架---代码记录---2021-7-25

第一次整合SSM框架笔记&代码记录,图书的增删改查,测试全部通过 文件路径 src main java com.simon.controller BookController.java com.simon.dao BookMapper.java BookMapper.xml com.simon.entity Books.java com.simon.service BookService.java BookServiceImpl.java resource applic

weixin_45838071的博客 161

SSM框架实战:简单图书管理与借阅系统

基于SSM框架实现简易图书管理与借阅系统(超详细) 1.javaweb开发 2.SSM实战 3.mysql应用 4.jsp 5.tomcat配置

luo___xi的博客 1万+

ssm+EasyUI的增删改查

最近在学ssm框架和一个前端EasyUI,就整合一下做了一个图书的增删改查的一个小项目,下面就是代码项目的目录结构web.xml文件配置&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.su...

a1824071的博客 5181

ssm增删改查实例项目_整合SSM(图书增删改查)

整合SSM环境要求环境:IDEAMySQL 5.7.19Tomcat 9Maven 3.6 要求:需要熟练掌握MySQL数据库,Spring,JavaWeb及MyBatis知识,简单的前端知识;数据库环境创建一个存放书籍数据的数据库表CREATE DATABASE `ssmbuild`; USE `ssmbuild`; DROP TABLE IF EXISTS `books`; CREATE...

weixin_39955418的博客 312

SSM框架整合入门案例

前面我们已经把、和三个框架进行了学习,今天主要的内容就是把这三个框架整合在一起完成我们的业务功能开发,具体如何来整合,我们一步步来学习。(1) 创建工程(2)SSM整合[重点是各个配置的编写](3)功能模块[与具体的业务模块有关]掌握上述的知识点后,接下来,我们就可以按照上述的步骤一步步的来完成SSM的整合。可以使用Maven的骨架创建 pom.xml添加SSM所需要的依赖jar包 步骤3:创建项目包结构 步骤5:创建JdbcConfig配置类 步骤6:创建MybatisConfig配置类 步骤7:创

爪蛙毁一生的博客 1997

SpringMVC【黑马】

SpringMVC

qwerasdctds的博客 824

SSM学习笔记-------SpringMVC(二)

完成SSM的整合开发 能够理解并实现统一结果封装与统一异常处理 能够完成前后台功能整合开发 掌握拦截器的编写

CSDN_Admin0的博客 3188
上一篇: REST风格和使用RESTful形式开发
下一篇: SpringMVC中拦截器的介绍
尘开的笔记
博客等级 码龄6年 41粉丝 70原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值