基于Spring MVC + Spring + MyBatis的【医院就诊挂号系统】

简介: 基于Spring MVC + Spring + MyBatis的【医院就诊挂号系统】

一、语言和环境


1.实现语言: JAVA语言。

2.环境要求: MyEclipse/Eclipse + Tomcat + MySQL。

3.使用技术: Spring MVC + Spring + MyBatis 或 JSP + Servlet + JavaBean + JDBC。



二、实现效果


9.png

实现能够对患者姓名,医师类别、科室的模糊查询,用户点击核销以后状态变为已就诊。


10.png


点击挂号实现基本信息的添加

11.png


三、实现代码


数据库:


SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for tb_patient
-- ----------------------------
DROP TABLE IF EXISTS `tb_patient`;
CREATE TABLE `tb_patient` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(50) DEFAULT NULL,
  `sex` varchar(10) DEFAULT NULL,
  `age` int(11) DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `department` varchar(50) DEFAULT NULL,
  `type` varchar(50) DEFAULT NULL,
  `price` decimal(9,2) DEFAULT NULL,
  `state` int(11) DEFAULT NULL,
  `register_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of tb_patient
-- ----------------------------
INSERT INTO `tb_patient` VALUES ('1', '张蕾', '女', '12', '13895463212', '儿科', '专家医师', '25.00', '1', '2021-07-18 12:23:00');
INSERT INTO `tb_patient` VALUES ('2', '刘德明', '男', '28', '13345623215', '骨科', '普通医师', '8.00', '0', '2021-07-18 12:23:00');
INSERT INTO `tb_patient` VALUES ('3', '李将军', '男', '38', '13578064788', '内科', '专家医师', '25.00', '1', '2021-07-17 12:23:00');
INSERT INTO `tb_patient` VALUES ('4', '张佩佩', '女', '44', '18214217246', '外科', '副主任医师', '17.00', '0', '2021-07-16 12:23:00');
INSERT INTO `tb_patient` VALUES ('5', '程聪明', '男', '29', '13652645964', '骨科', '副主任医师', '17.00', '0', '2021-08-08 16:21:52');


项目Java代码:


目录结构


12.png


JAR包:

13.png


14.png


代码:


=src
> com.mhys.crm.controller
HospitalContrller.java


package com.mhys.crm.controller;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.mhys.crm.dao.TbPatientMapper;
import com.mhys.crm.entity.TbPatient;
@Controller
public class HospitalContrller {
  @Resource
  private TbPatientMapper tbPatientMapper;
  @RequestMapping("/select")
  public String getList(Model model) {
    List<TbPatient> selctAll = tbPatientMapper.selectAlls();
    System.out.println(selctAll);
    model.addAttribute("selctAll", selctAll);
    return "info";
  }
  @RequestMapping("/list")
  public String getAll(Model model, String name, String type, String dep) {
    List<TbPatient> selctAll = tbPatientMapper.selectAll(name, type, dep);
    System.out.println(name+"==="+type+"==="+dep);
    model.addAttribute("selctAll", selctAll);
    return "info";
  }
  @RequestMapping("/upd")
  public String upDev(Model model,int id) {
    int update = tbPatientMapper.update(id);
    return "redirect:/select.do";
  }
  @RequestMapping("/adds")
  public String adds(Model model) {
    return "addInfo";
  }
  @RequestMapping("/insert")
  public String toaddDev(Model model,TbPatient tb) {
    tbPatientMapper.insert(tb);
      return "redirect:/select.do";
  }
}


> com.mhys.crm.dao
TbPatientMapper.java
package com.mhys.crm.dao;
import com.mhys.crm.entity.TbPatient;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TbPatientMapper {
    int deleteByPrimaryKey(Integer id);
    int insert(TbPatient record);
    TbPatient selectByPrimaryKey(Integer id);
    List<TbPatient> selectAlls();
    int updateByPrimaryKey(TbPatient record);
    int update(Integer id);
    List<TbPatient> selectAll(@Param("name")String name,@Param("type")String type,@Param("dep")String dap);
}


TbPatientMapper.xml


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.mhys.crm.dao.TbPatientMapper" >
  <resultMap id="BaseResultMap" type="com.mhys.crm.entity.TbPatient" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="sex" property="sex" jdbcType="VARCHAR" />
    <result column="age" property="age" jdbcType="INTEGER" />
    <result column="phone" property="phone" jdbcType="VARCHAR" />
    <result column="department" property="department" jdbcType="VARCHAR" />
    <result column="type" property="type" jdbcType="VARCHAR" />
    <result column="price" property="price" jdbcType="DECIMAL" />
    <result column="state" property="state" jdbcType="INTEGER" />
    <result column="register_time" property="registerTime" jdbcType="TIMESTAMP" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tb_patient
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.mhys.crm.entity.TbPatient" >
    insert into tb_patient (id, name, sex, 
      age, phone, department, 
      type, price, state, 
      register_time)
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, 
      #{age,jdbcType=INTEGER}, #{phone,jdbcType=VARCHAR}, #{department,jdbcType=VARCHAR}, 
      #{type,jdbcType=VARCHAR}, #{price,jdbcType=DECIMAL}, #{state,jdbcType=INTEGER}, 
      #{registerTime,jdbcType=TIMESTAMP})
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.mhys.crm.entity.TbPatient" >
    update tb_patient
    set name = #{name,jdbcType=VARCHAR},
      sex = #{sex,jdbcType=VARCHAR},
      age = #{age,jdbcType=INTEGER},
      phone = #{phone,jdbcType=VARCHAR},
      department = #{department,jdbcType=VARCHAR},
      type = #{type,jdbcType=VARCHAR},
      price = #{price,jdbcType=DECIMAL},
      state = #{state,jdbcType=INTEGER},
      register_time = #{registerTime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <select id="selectAlls" resultMap="BaseResultMap" >
    select id, name, sex, age, phone, department, type, price, state, register_time
    from tb_patient
  </select>
  <select id="selectAll" resultMap="BaseResultMap" >
    select id, name, sex, age, phone, department, type, price, state, register_time
    from tb_patient
    <where>
    <if test="name!=null and name!=''">
      and name = #{name}
    </if>
  <if test="type!=null and type!=''">
      and type = #{type}
    </if>
    <if test="dep!=null and dep!=''">
      and department = #{dep}
    </if>
    </where>
  </select>
  <update id="update" parameterType="com.mhys.crm.entity.TbPatient" >
    update tb_patient set state=1 where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>


> com.mhys.crm.entity
TbPatient.java
package com.mhys.crm.entity;
import java.math.BigDecimal;
import java.util.Date;
public class TbPatient {
    private Integer id;
    private String name;
    private String sex;
    private Integer age;
    private String phone;
    private String department;
    private String type;
    private BigDecimal price;
    private Integer state;
    private Date registerTime;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex == null ? null : sex.trim();
    }
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone == null ? null : phone.trim();
    }
    public String getDepartment() {
        return department;
    }
    public void setDepartment(String department) {
        this.department = department == null ? null : department.trim();
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type == null ? null : type.trim();
    }
    public BigDecimal getPrice() {
        return price;
    }
    public void setPrice(BigDecimal price) {
        this.price = price;
    }
    public Integer getState() {
        return state;
    }
    public void setState(Integer state) {
        this.state = state;
    }
    public Date getRegisterTime() {
        return registerTime;
    }
    public void setRegisterTime(Date registerTime) {
        this.registerTime = registerTime;
    }
  @Override
  public String toString() {
    return "TbPatient [id=" + id + ", name=" + name + ", sex=" + sex + ", age=" + age + ", phone=" + phone
        + ", department=" + department + ", type=" + type + ", price=" + price + ", state=" + state
        + ", registerTime=" + registerTime + "]";
  }
}


> com.mhys.crm.service.impl
HospitalService.java


package com.mhys.crm.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.mhys.crm.dao.TbPatientMapper;
import com.mhys.crm.entity.TbPatient;
public class HospitalService {
  @Resource
  private TbPatientMapper tbPatientMapper;
  @RequestMapping("/select")
  public String getList(Model model) {
    List<TbPatient> selctAll = tbPatientMapper.selectAlls();
    System.out.println(selctAll);
    model.addAttribute("selctAll", selctAll);
    return "info";
  }
  @RequestMapping("/list")
  public String getAll(Model model, String name, String type, String dep) {
    List<TbPatient> selctAll = tbPatientMapper.selectAll(name, type, dep);
    System.out.println(name+"==="+type+"==="+dep);
    model.addAttribute("selctAll", selctAll);
    return "info";
  }
  @RequestMapping("/upd")
  public String upDev(Model model,int id) {
    int update = tbPatientMapper.update(id);
    return "redirect:/select.do";
  }
  @RequestMapping("/adds")
  public String adds(Model model) {
    return "addInfo";
  }
  @RequestMapping("/insert")
  public String toaddDev(Model model,TbPatient tb) {
    tbPatientMapper.insert(tb);
      return "redirect:/select.do";
  }
}


=resource
> mybatis
SqlMapConfig.xml


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
  <typeAliases>
    <package name="com.mhys.crm.entity"/>
  </typeAliases>
</configuration>


> spring
applicationContext-dao.xml


<?xml version="1.0" encoding="UTF-8"?>
<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">
  <context:property-placeholder location="classpath:database.properties"></context:property-placeholder>
  <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
    <property name="driverClassName" value="${jdbc.driver}"></property>
    <property name="Url" value="${jdbc.url}"></property>
    <property name="username" value="${jdbc.username}"></property>
    <property name="password" value="${jdbc.password}"></property>
  </bean>
  <!-- 配置SqlSessionFactory -->
  <bean class="org.mybatis.spring.SqlSessionFactoryBean">
    <!-- 设置MyBatis核心配置文件 -->
    <property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml" />
    <!-- 设置数据源 -->
    <property name="dataSource" ref="dataSource" />
  </bean>
  <!-- 配置Mapper扫描 -->
  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <!-- 设置Mapper扫描包 -->
    <property name="basePackage"  value="com.mhys.crm.dao" />
  </bean>
  <!-- 配置事务管理器 -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      <property name="dataSource" ref="dataSource"></property>
    </bean>
    <!-- 开启注解方式管理AOP事务 -->
    <tx:annotation-driven transaction-manager="transactionManager" />
</beans>



applicationContext-service.xml


<?xml version="1.0" encoding="UTF-8"?>
<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">
    <!-- 配置Service扫描 -->
  <context:component-scan base-package="com" />
  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"></property>
  </bean>
  <tx:annotation-driven transaction-manager="transactionManager" />
</beans>


spring-mvc.xml


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:mvc="http://www.springframework.org/schema/mvc"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">
    <!-- 配置Controller扫描 -->
  <context:component-scan base-package="com.mhys.crm.controller" />
  <mvc:annotation-driven />
  <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/jsp/" />
    <property name="suffix" value=".jsp" />
  </bean>
</beans>



> database.properties


jdbc.url=jdbc:mysql://localhost:3306/hospital_db?useUnicode=true&characterEncoding=UTF-8&useSSL=false
jdbc.username=root
jdbc.password=123456
jdbc.driver=com.mysql.jdbc.Driver

=JSP页面
> /WEB-INF/jsp/
addInfo.jsp


<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>挂号</title>
  </head>
  <body>
    <form action="insert.do" method="post">
      <table border="" cellspacing="" cellpadding="">
        <tr>
          <td>姓名</td>
          <td><input type="text" name="name" value="" /></td>
        </tr>
        <tr>
          <td>性别</td>
          <td><input type="text" name="sex" value=""/></td>
        </tr>
        <tr>
          <td>年龄</td>
          <td><input type="text" name="age" value=""/></td>
        </tr>
        <tr>
          <td>电话</td>
          <td><input type="text" name="phone" value=""/></td>
        </tr>
        <tr>
          <td>医师类别</td>
          <td><input type="text" name="department" value=""/></td>
        </tr>
        <tr>
          <td>价格</td>
          <td><input type="text" name="price" value=""/></td>
        </tr>
        <tr>
          <td>挂号时间</td>
          <td><input type="text" name="registerTime" value=""/></td>
        </tr>
      </table>
      <input type="submit" value="确定" />
    </form>
  </body>
</html>


info.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>医院就诊挂号系统</title>
<style type="text/css">
  form{
    padding: 20px;
  }
  #warp{
    margin:0 auto;
    width: 60%
  }
</style>
</head>
<body>
  <h1 align="center">医院就诊挂号系统</h1>
  <div id="warp">
    <form action="list.do">
    患者姓名:<input type="text" name="name">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    医师类别:
        <select name="type">
          <option value="" >=不限=</option>
          <option value="专家医师" >专家医师</option>
          <option value="普通医师" >普通医师</option>
          <option value="副主任医师" >副主任医师</option>
        </select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    科室:<input type="text" name="dep">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input type="submit" value="查询">&nbsp;&nbsp;&nbsp;
    <input type="button" value="挂号" onclick="add()">
  </form>
  <table style="margin-bottom: 30px;" width="100%" border="1px" cellpadding="11" cellspacing="0">
    <tr>
      <th>编号</th>
      <th>姓名</th>
      <th>性别</th>
      <th>年龄</th>
      <th>电话</th>
      <th>科室</th>
      <th>医师类别</th>
      <th>价格</th>
      <th>挂号时间</th>
      <th>状态</th>
      <th>操作</th>
    </tr>
    <c:forEach var="list" items="${selctAll }">
      <tr>
        <td>${list.id }</td>
        <td>${list.name }</td>
        <td>${list.sex }</td>
        <td>${list.age }</td>
        <td>${list.phone }</td>
        <td>${list.department }</td>
        <td>${list.type }</td>
        <td>${list.price }</td>
        <td><fmt:formatDate value="${list.registerTime }" pattern="yyyy-MM-dd"/></td>
        <td>
          <c:if test="${list.state==0}">
              未就诊
            </c:if>
          <c:if test="${list.state==1}">
              已就诊
            </c:if>
        </td>
        <td>
          <c:if test="${list.state==0}">
              <a href="javascript:if(confirm('确实要核销该挂号信息吗?'))location='upd.do?id=${list.id }'">核销</a>
            </c:if>
          <%-- <c:if test="${list.state==1}">
              已就诊
            </c:if> --%>
        </td>
      </tr>
    </c:forEach>
  </table>
  </div>
  <script type="text/javascript">
  function add() {
    location.href="adds.do";
  }
  </script>
</body>
</html>


index.jsp


<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>XXX系统</title>
</head>
<body>
<script>
  window.location.href="<%=basePath%>/select.do";
</script>
</body>
</html>


相关文章
|
30天前
|
前端开发 Java 微服务
《深入理解Spring》:Spring、Spring MVC与Spring Boot的深度解析
Spring Framework是Java生态的基石,提供IoC、AOP等核心功能;Spring MVC基于其构建,实现Web层MVC架构;Spring Boot则通过自动配置和内嵌服务器,极大简化了开发与部署。三者层层演进,Spring Boot并非替代,而是对前者的高效封装与增强,适用于微服务与快速开发,而深入理解Spring Framework有助于更好驾驭整体技术栈。
|
8月前
|
XML Java 数据库连接
微服务——SpringBoot使用归纳——Spring Boot集成MyBatis——基于 xml 的整合
本教程介绍了基于XML的MyBatis整合方式。首先在`application.yml`中配置XML路径,如`classpath:mapper/*.xml`,然后创建`UserMapper.xml`文件定义SQL映射,包括`resultMap`和查询语句。通过设置`namespace`关联Mapper接口,实现如`getUserByName`的方法。Controller层调用Service完成测试,访问`/getUserByName/{name}`即可返回用户信息。为简化Mapper扫描,推荐在Spring Boot启动类用`@MapperScan`注解指定包路径避免逐个添加`@Mapper`
420 0
|
8月前
|
JSON 前端开发 Java
微服务——SpringBoot使用归纳——Spring Boot中的MVC支持——@RequestBody
`@RequestBody` 是 Spring 框架中的注解,用于将 HTTP 请求体中的 JSON 数据自动映射为 Java 对象。例如,前端通过 POST 请求发送包含 `username` 和 `password` 的 JSON 数据,后端可通过带有 `@RequestBody` 注解的方法参数接收并处理。此注解适用于传递复杂对象的场景,简化了数据解析过程。与表单提交不同,它主要用于接收 JSON 格式的实体数据。
700 0
|
5月前
|
Java 数据库连接 数据库
Spring boot 使用mybatis generator 自动生成代码插件
本文介绍了在Spring Boot项目中使用MyBatis Generator插件自动生成代码的详细步骤。首先创建一个新的Spring Boot项目,接着引入MyBatis Generator插件并配置`pom.xml`文件。然后删除默认的`application.properties`文件,创建`application.yml`进行相关配置,如设置Mapper路径和实体类包名。重点在于配置`generatorConfig.xml`文件,包括数据库驱动、连接信息、生成模型、映射文件及DAO的包名和位置。最后通过IDE配置运行插件生成代码,并在主类添加`@MapperScan`注解完成整合
926 1
Spring boot 使用mybatis generator 自动生成代码插件
|
4月前
|
前端开发 Java API
Spring Cloud Gateway Server Web MVC报错“Unsupported transfer encoding: chunked”解决
本文解析了Spring Cloud Gateway中出现“Unsupported transfer encoding: chunked”错误的原因,指出该问题源于Feign依赖的HTTP客户端与服务端的`chunked`传输编码不兼容,并提供了具体的解决方案。通过规范Feign客户端接口的返回类型,可有效避免该异常,提升系统兼容性与稳定性。
308 0
|
5月前
|
Java 数据库连接 API
Java 对象模型现代化实践 基于 Spring Boot 与 MyBatis Plus 的实现方案深度解析
本文介绍了基于Spring Boot与MyBatis-Plus的Java对象模型现代化实践方案。采用Spring Boot 3.1.2作为基础框架,结合MyBatis-Plus 3.5.3.1进行数据访问层实现,使用Lombok简化PO对象,MapStruct处理对象转换。文章详细讲解了数据库设计、PO对象实现、DAO层构建、业务逻辑封装以及DTO/VO转换等核心环节,提供了一个完整的现代化Java对象模型实现案例。通过分层设计和对象转换,实现了业务逻辑与数据访问的解耦,提高了代码的可维护性和扩展性。
214 1
|
4月前
|
SQL Java 数据库连接
Spring、SpringMVC 与 MyBatis 核心知识点解析
我梳理的这些内容,涵盖了 Spring、SpringMVC 和 MyBatis 的核心知识点。 在 Spring 中,我了解到 IOC 是控制反转,把对象控制权交容器;DI 是依赖注入,有三种实现方式。Bean 有五种作用域,单例 bean 的线程安全问题及自动装配方式也清晰了。事务基于数据库和 AOP,有失效场景和七种传播行为。AOP 是面向切面编程,动态代理有 JDK 和 CGLIB 两种。 SpringMVC 的 11 步执行流程我烂熟于心,还有那些常用注解的用法。 MyBatis 里,#{} 和 ${} 的区别很关键,获取主键、处理字段与属性名不匹配的方法也掌握了。多表查询、动态
147 0
|
4月前
|
JSON 前端开发 Java
第05课:Spring Boot中的MVC支持
第05课:Spring Boot中的MVC支持
247 0
|
5月前
|
SQL Java 数据库
解决Java Spring Boot应用中MyBatis-Plus查询问题的策略。
保持技能更新是侦探的重要素质。定期回顾最佳实践和新技术。比如,定期查看MyBatis-Plus的更新和社区的最佳做法,这样才能不断提升查询效率和性能。
220 1
|
8月前
|
XML Java 数据库连接
微服务——SpringBoot使用归纳——Spring Boot集成MyBatis——基于注解的整合
本文介绍了Spring Boot集成MyBatis的两种方式:基于XML和注解的形式。重点讲解了注解方式,包括@Select、@Insert、@Update、@Delete等常用注解的使用方法,以及多参数时@Param注解的应用。同时,针对字段映射不一致的问题,提供了@Results和@ResultMap的解决方案。文章还提到实际项目中常结合XML与注解的优点,灵活使用两者以提高开发效率,并附带课程源码供下载学习。
661 0