Spring+Spring MVC+MyBatis综合案例

Spring+Spring MVC+MyBatis


环境:

  • java EE Version: 2020-06 (4.16.0)
  • spring-framework-5.0.1
  • mybatis-3.5.6
  • 8.0.21 MySQL Community Server - GPL
  • navicat
  • chrome

导入需要的jar包,最好都放在WEB-INF/lib下边

  1. spring下载: https://repo.spring.io/webapp/#/artifacts/browse/tree/General/libs-release-local/org/springframework/spring/5.0.1.RELEASE
  2. mybatis: https://github.com/mybatis/mybatis-3/releases
  3. mybatis-spring-1.3.1.jar
  4. mysql-connector-java-8.0.16.jar

最终需要的jar包清单

配置web.xml文件

  • 注册spring配置文件的位置
  • 注册ServletContext监听器
  • 注册字符集过滤器
  • 配置Spring MVC 核心控制器
<?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>ssm1</display-name>
 <!-- 注册spring配置文件的位置 -->
<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 注册ServletContext监听器,创建spring容器 -->
<listener>
	<listener-class>
		org.springframework.web.context.ContextLoaderListener
	</listener-class>
</listener>

<!--  注册字符集过滤器-->
<filter>
        <filter-name>characterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>characterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
   <!--  配置spring核心控制器 -->
  <servlet>
	  <servlet-name>springmvc</servlet-name>
	  <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
	  <init-param>
		  <param-name>contextConfigLocation</param-name>
		  <param-value>classpath:springmvc.xml</param-value>
	  </init-param>
	  <load-on-startup>1</load-on-startup>
  </servlet>
  
  <servlet-mapping>
	  <servlet-name>springmvc</servlet-name>
	  <url-pattern>*.do</url-pattern>  
  </servlet-mapping>
  
  
  <context-param>
	  <param-name>spring.profiles.active</param-name>
	  <param-value>dev</param-value>
  </context-param>
  <context-param>
	  <param-name>spring.profiles.default</param-name>
	  <param-value>dev</param-value>
  </context-param>
  <context-param>
	  <param-name>spring.liveBeansView.mbeanDomain</param-name>
	  <param-value>dev</param-value>
  </context-param>
  
  <welcome-file-list>   
    <welcome-file>index.jsp</welcome-file>   
  </welcome-file-list>
</web-app>

创建 src/applicationContext.xml 注册数据源 DataSource

  1. 配置数据源 c3p0 数据源
  2. 注册事务
  • 定义事务管理器

  • 编写通知

  • 编写AOP 让Spring自动切入事务到目标切面

  • 注册MyBatis的配置文件

  • 配置SqlSessionFactory

    • 注册Mapper配置扫描器
    • 配置扫描service层
<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd">
<!-- 
	<context:property-placeholder
		location="classpath:jdbc.properties" /> -->

	<!-- 配置数据源c3p0数据源 -->
	<bean id="dataSource"
		class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="driverClass">
			<value>com.mysql.cj.jdbc.Driver</value>
		</property>
		<property name="jdbcUrl">
			<value>jdbc:mysql://127.0.0.1:3306/mybatis?serverTimezone=UTC&amp;useUnicode=true&amp;characterEncoding=utf8</value>
		</property>
		<property name="user">
			<value>root</value>
		</property>
		<property name="password">
			<value>123456</value>
		</property>
		
		<!-- 如果池中数据连接不够时一次增长多少个 -->
		<property name="acquireIncrement" value="5"></property>
		<!-- 初始化数据库连接池时连接的数量 -->
		<property name="initialPoolSize" value="20"></property>
		<!-- 数据库连接池中的最大的数据库连接数 -->
		<property name="maxPoolSize" value="25"></property>
		<!-- 数据库连接池中的最小的数据库连接数 -->
		<property name="minPoolSize" value="5"></property>
	</bean>

	<!-- 定义事务管理器 -->
	<bean id="txManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>

	<!-- 编写通知 -->
	<tx:advice id="txAdvice" transaction-manager="txManager">
		<tx:attributes>
			<tx:method name="*" propagation="REQUIRED"
				isolation="DEFAULT" read-only="false" />
		</tx:attributes>
	</tx:advice>

	<!-- 编写AOP,让spring自动切入事务到目标切面 -->
	<aop:config>
		<!-- 定义切入点 -->
		<aop:pointcut id="txPointcut"
			expression="execution(* com.gen.service.*.*(..))" />
		<!-- 将事务通知与切入点组合 -->
		<aop:advisor advice-ref="txAdvice"
			pointcut-ref="txPointcut" />
	</aop:config>

	<!-- 配置sqlSessionFactory -->
	<bean id="sqlSessionFactory"
		class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<!-- 指定mybatis配置文件的位置 -->
		<property name="configLocation"
			value="classpath:mybatis-config.xml"></property>
	</bean>

	<!-- 注册Mapper扫描配置器 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="sqlSessionFactory" ref="sqlSessionFactory" />
		<property name="basePackage" value="com.gen.dao" />
	</bean>


	<!-- 配置扫描service层 -->
	<context:component-scan
		base-package="com.gen.service" />

</beans>

创建 src/mybatis-config.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>
		<typeAlias alias="Student" type="com.gen.entity.Student"/>
	</typeAliases>	
	<mappers>
		<mapper resource="com/gen/dao/StudentMapper.xml"/>		
	</mappers>
</configuration>

创建 src/springmvc.xml

  • 配置包扫描器 扫描@Controller
  • 加载注解驱动
  • 配置视图解释器 逻辑视图前缀+逻辑视图后缀
<?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:mvc="http://www.springframework.org/schema/mvc"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" 
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
		http://www.springframework.org/schema/beans/spring-beans.xsd 
		http://www.springframework.org/schema/mvc 
		http://www.springframework.org/schema/mvc/spring-mvc.xsd 
		http://www.springframework.org/schema/context 
		http://www.springframework.org/schema/context/spring-context.xsd 
		http://www.springframework.org/schema/aop 
		http://www.springframework.org/schema/aop/spring-aop.xsd 
		http://www.springframework.org/schema/tx 
		http://www.springframework.org/schema/tx/spring-tx.xsd">		

	<!-- 配置包扫描器,扫描@Controller注解的类 -->
	<context:component-scan base-package="com.gen.controller"/>

	<!-- 加载注解驱动 -->
	<mvc:annotation-driven/>
	<!-- 配置视图解释器 -->
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<!-- 逻辑视图前缀 -->
		<property name="prefix" value="/WEB-INF/jsp/"></property>
		<!-- 逻辑视图后缀,匹配模式:前缀+逻辑视图+后缀,形成完整路径名 -->
		<property name="suffix" value=".jsp"></property> 
	</bean>  
</beans>

创建数据表

CREATE TABLE `users` (
  `id` int NOT NULL AUTO_INCREMENT,
  `username` varchar(32) NOT NULL COMMENT '用户名称',
  `sex` char(1) DEFAULT NULL COMMENT '性别',
  `address` varchar(256) DEFAULT NULL COMMENT '地址',
  `idnumber` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_id_index` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=20201014 DEFAULT CHARSET=utf8

后续开发

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uUpqRS86-1616756545636)(C:\Users\ShiGen\Desktop\DestopImg\MAC14.jpg)]

创建包 com.gen.entity 和实体类 Student 省略setter getter constructor方法

package com.gen.entity;

public class Student {
	private Integer id;
	private String username;
	private Character sex;
	private String address;
	private String idnumber;

创建包 com.gen.dao 创建接口 IStudentDao 和对应的 StudentMapper.xml

package com.gen.dao;

import java.util.List;

import com.gen.entity.Student;

public interface IStudentDao {
	public int add(Student student);

	public int delete(Integer id);

	public int update(Student student);

	public Student selectOne(Integer id);

	public List<Student> selectAll();
}
<?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.gen.dao.IStudentDao">

	<resultMap type="com.gen.entity.Student"
		id="studentResultMap">
		<id column="id" property="id" />
		<result column="username" property="username" />
		<result column="sex" property="sex" />
		<result column="address" property="address" />
		<result column="idnumber" property="idnumber" />
	</resultMap>

	<select id="selectAll" resultMap="studentResultMap"
		resultType="com.gen.entity.Student">
		SELECT * FROM users
	</select>

	<select id="selectOne" resultMap="studentResultMap"
		parameterType="int">
		SELECT id,username,sex,address,idnumber
		FROM users
		where
		id=#{id}
	</select>

	<insert id="add" parameterType="Student">INSERT INTO
		users(id, username,
		sex, address, idnumber)
		VALUES(#{id}, #{username}, #{sex},
		#{address},#{idnumber})
	</insert>

	<delete id="delete" parameterType="Integer">
		delete from users where
		id=#{id}
	</delete>

	<update id="update" parameterType="Student">
		UPDATE users SET
		username=#{username},sex=#{sex},address=#{address},idnumber=#{idnumber}
		WHERE id= #{id}
	</update>

</mapper>

创建包 com.gen.service 创建接口 IStudentService 以及实现类 StudentServiceImpl

package com.gen.service;

import java.util.List;

import com.gen.entity.Student;

public interface IStudentService {
	public int add(Student student);

	public int delete(Integer id);

	public int update(Student student);

	public Student selectOne(Integer id);

	public List<Student> selectAll();
	
	public void testTransaction();
}
package com.gen.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gen.dao.IStudentDao;
import com.gen.entity.Student;
@Service
public class StudentServiceImpl implements IStudentService{
	@Autowired
	private IStudentDao studentDao;
	
	public IStudentDao getStudentDao() {
		return studentDao;
	}

	public void setStudentDao(IStudentDao studentDao) {
		this.studentDao = studentDao;
	}

	@Override
	public int add(Student student) {
		return studentDao.add(student);
	}

	@Override
	public int delete(Integer id) {
		return studentDao.delete(id);
	}

	@Override
	public int update(Student student) {
		return studentDao.update(student);
	}

	@Override
	public Student selectOne(Integer id) {
		return studentDao.selectOne(id);
	}

	@Override
	public List<Student> selectAll() {
		return studentDao.selectAll();
	}

	@Override
	public void testTransaction() {
		delete(4);
		Integer.parseInt("a");
		delete(3);		
	}

}

创建包 com.gen.controller 创建控制器类

package com.gen.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.gen.entity.Student;
import com.gen.service.IStudentService;

@Controller
public class StudentController {
	@Autowired
	IStudentService studentService;

	@RequestMapping("/addPage.do")
	public String addPage() {
		return "add";
	}
	
	@RequestMapping("/add.do")
	public ModelAndView add(Student student) {
		ModelAndView modelAndView = new ModelAndView();
		studentService.add(student);
		modelAndView.setViewName("redirect:selectAll.do");
		return modelAndView;
	}
	
	@RequestMapping("/delete.do")
	public ModelAndView delete(Integer id) {
		ModelAndView modelAndView = new ModelAndView();
		studentService.delete(id);
		modelAndView.setViewName("redirect:selectAll.do");
		return modelAndView;
	}
	
	@RequestMapping("/update.do")
	public ModelAndView update(Student student) {
		ModelAndView modelAndView = new ModelAndView();
		studentService.update(student);
		modelAndView.setViewName("redirect:selectAll.do");
		return modelAndView;
	}
	
	@RequestMapping("/selectAll.do")
	public ModelAndView selectAll() {
		ModelAndView modelAndView = new ModelAndView();
		List<Student> all = studentService.selectAll();
		modelAndView.addObject("all", all);
		modelAndView.setViewName("list");
		return modelAndView;
	}
	
	@RequestMapping("/selectOne.do")
	public ModelAndView selectOne(Integer id) {
		ModelAndView modelAndView = new ModelAndView();
		Student student = studentService.selectOne(id);
		modelAndView.addObject("student", student);
		modelAndView.setViewName("detail");
		return modelAndView;
	}
	
	@RequestMapping("/toUpdate.do")
	public ModelAndView toUpdate(Integer id) {
		ModelAndView modelAndView = new ModelAndView();
		Student student = studentService.selectOne(id);
		modelAndView.addObject("student", student);
		modelAndView.setViewName("update");
		return modelAndView;
	}
	
}

在WebContent/WEB-INF 下创建文件夹jsp 创建相应的页面

  • add.jsp
  • detail.jsp
  • lit.jsp
  • update.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>add.jsp</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<style type="text/css">
input {
	width: 100%;
}
</style>
</head>
<body>
	<h2>add.jsp</h2>
	<form action="add.do" method="post">
		<table style="width: 80%;">
			<tr>
				<td>id:</td>
				<td><input type="text" name="id" id="id"></td>
				<td></td>
			</tr>
			<tr>
				<td>username:</td>
				<td><input type="text" name="username" id="username">
				<td></td>
			</tr>
			<tr>
				<td>sex:</td>
				<td><input type="text" name="sex" id="sex"></td>
				<td></td>
			</tr>
			<tr>
				<td>address:</td>
				<td><input type="text" name="address" id="address"></td>
				<td></td>
			</tr>
			<tr>
				<td>idnumber:</td>
				<td><input type="text" name="idnumber" id="idnumber"></td>
				<td></td>
			<tr>
			<tr>
				<td colspan="3">
					<input type="submit" value="提交" style="width: 100px;background-color: #3EDE83;">
					<input type="reset" value="重置" style="width: 100px;background-color: #F0283D;">
				</td>
			</tr>	
		</table>
	</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>detail.jsp</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
	<h2>detail.jsp</h2>
	<table>
		<tr>
			<td>id:</td>
			<td>${student.id }</td>
		</tr>
		<tr>
			<td>username:</td>
			<td>${student.username }</td>
		</tr>
		<tr>
			<td>sex:</td>
			<td>${student.sex }</td>
		</tr>
		<tr>
			<td>address:</td>
			<td>${student.address }</td>
		</tr>
		<tr>
			<td>idnumber:</td>
			<td>${student.idnumber }</td>
		</tr>
		<tr>
			<td></td>
			<td><a href="selectAll.do">返回</a></td>
		</tr>
	</table>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>list.jsp</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
	<h2>list.jsp</h2>
	<table>
		<tr>
			<th>id:</th>
			<th>username:</th>
			<th>sex:</th>
			<th>address:</th>
			<th>idnumber:</th>
			<th colspan="3">poeration:</th>
		</tr>
		<c:forEach items="${all}" var="stu">
			<tr>
				<td>${stu.id}</td>
				<td>${stu.username}</td>
				<td>${stu.sex}</td>
				<td>${stu.address}</td>
				<td>${stu.idnumber }</td>
				<td><a href="selectOne.do?id=${stu.id}">详细信息&nbsp;</a></td>
				<td><a href="toUpdate.do?id=${stu.id}">修改&nbsp;</a></td>
				<td><a class="delete" href="delete.do?id=${stu.id}"
					οnclick="return confirm('你确认要删除该学生信息吗?')">删除&nbsp;</a></td>
			</tr>
		</c:forEach>
	</table>
<a href="addPage.do">添加用户</a>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>update.jsp</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<style type="text/css">
input{width: 100%}
</style>
</head>
<body>
	<h2>update.jsp</h2>
	<form action="update.do" method="post">
		<table style="width: 80%;">
			<tr>
				<td>id:</td>
				<td><input type="text" name="id" value="${student.id}"
					readonly="readonly" /></td>
				<td></td>
			</tr>
			<tr>
				<td>username:</td>
				<td><input type="text" name="username"
					value="${student.username}" /></td>
				<td></td>
			</tr>
			<tr>
				<td>sex:</td>
				<td><input type="text" name="sex" value="${student.sex}" /></td>
				<td></td>
			</tr>
			<tr>
				<td>address:</td>
				<td><input type="text" name="address"
					value="${student.address}" /></td>
				<td></td>
			</tr>
			<tr>
				<td>idnumber:</td>
				<td><input type="text" name="idnumber"
					value="${student.idnumber }"></td>
				<td></td>
			</tr>
			<tr>
				<td><input type="submit" value="修改" style="background-color: #3EDE83;"/></td>
				<td></td>
				<td></td>
			</tr>
		</table>
	</form>
</body>
</html>

其它的样式表和生成日志的配置文件

  • /SSM/WebContent/css/style.css
  • /SSM/src/jdbc.properties
table{width: 100%;margin: 0 auto; border-collapse: collapse;border: 2px solid black;}
tr,th,td{border: 1px solid orange;}
a{display: inline-block;background-color: #3EDE83;border-radius: 5%;padding: 4px;text-decoration: none;}
a.delete{background-color:#F0283D;}
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/mybatis?serverTimezone=UTC&amp;useUnicode=true&amp;characterEncoding=utf8
jdbc.username=root
jdbc.password=123456

项目架构

在这里插入图片描述

最终的效果

请添加图片描述
请添加图片描述
请添加图片描述
在这里插入图片描述

请添加图片描述

总结

  • 不足:
  1. spring的反转和切片操作略显生疏
  2. 配置文件/SSM/src/jdbc.properties的读取存在问题
  • 后期可以加强的地方:
  1. UI设计
  2. 前端和后端数据的验证
  3. 增加业务
  4. 实现拦截器来控制权限

Plus版实现完整的功能

需要的技术:JavaScript jQuery以及各种插件以及以上SSM技术,剩下的后期再加上

实现的完整效果:完整的可实现的教务系统

数据库:mybatis

  • users

字段类型是否为空备注
idint主键
usernamevarchar(32)用户名,支持英文的
sexchar(1)一个字符 男/女
addressvarchar(256)住址
idnumbervarchar(18)身份证号(中国)
  • course

字段类型是否为空备注
courseidvarchar(30)课程号,主键
coursenamevarchar(60)课程名
creditfloat学分
departidint院系号
teacherint教师号
  • user_course

字段类型是否为空备注
idint序列号自增
uidint用户ID
courseidvarchar(30)课程ID
  • classes

字段类型是否为空备注
cidvarchar(20)班级号
cnamevarchar(40)班级名
departidint院系号
  • user_class

字段类型是否为空备注
idint序列号 自增
uidint用户ID
cidvarchar(20)班级号
  • role

字段类型是否为空备注
ridint角色ID
describvarchar(20)描述(中文)
  • user_role

字段类型是否为空备注
idint用户ID
ridint角色ID
  • passTable

字段类型是否为空备注
idint用户ID,主键
passwordvarchar(60)加盐之后的密码
saltvarchar(60)
  • depart

字段类型是否为空备注
departidint院系ID
namevarchar(32)院系名字
deanidint院长ID
  • record

字段类型是否为空备注
idint用户ID 主键
operatorint注册的操作员
registrationtimevarchar(20)注册时间
logintimevarchar(20)登录时间
ipvarchar(39)登录地址

需要实现的业务逻辑

  • passtable

字段类型是否为空备注
idint用户ID,主键
passwordvarchar(60)加盐之后的密码
saltvarchar(60)
  • depart

字段类型是否为空备注
departidint院系ID
namevarchar(32)院系名字
deanidint院长ID
  • record

字段类型是否为空备注
idint用户ID 主键
operatorint注册的操作员
registrationtimevarchar(20)注册时间
logintimevarchar(20)登录时间
ipvarchar(39)登录地址

##后期待开发

Spring Boot 是一个用于构建微服务的开源框架,它能够快速搭建项目并且提供了许多便捷的功能和特性。Spring Security 是一个用于处理认证和授权的框架,可以保护我们的应用程序免受恶意攻击。JWT(JSON Web Token)是一种用于身份验证的开放标准,可以被用于安全地传输信息。Spring MVC 是一个用于构建 Web 应用程序的框架,它能够处理 HTTP 请求和响应。MyBatis 是一个用于操作数据库的框架,可以简化数据库操作和提高效率。Redis 是一种高性能的键值存储系统,可以用于缓存与数据存储。 基于这些技术,可以搭建一个商城项目。Spring Boot 可以用于构建商城项目的后端服务,Spring Security 可以确保用户信息的安全性,JWT 可以用于用户的身份验证,Spring MVC 可以处理前端请求,MyBatis 可以操作数据库,Redis 可以用于缓存用户信息和商品信息。 商城项目的后端可以使用 Spring Boot 和 Spring Security 来搭建,通过 JWT 来处理用户的身份验证和授权。数据库操作可以使用 MyBatis 来简化与提高效率,同时可以利用 Redis 来缓存一些常用的数据和信息,提升系统的性能。前端请求则可以通过 Spring MVC 来处理,实现商城项目的整体功能。 综上所述,借助于 Spring Boot、Spring Security、JWT、Spring MVCMyBatis 和 Redis 这些技术,可以构建出一个高性能、安全可靠的商城项目,为用户提供良好的购物体验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值