(一)springboot+shiro+iview实现用户登录以及基本的增删改查
前言
新手小白最近在学springboot,现在最新的是前后端分离的思想但是对于刚刚从事这行的小白来说可能先从前后端不分离入手要简单一点,本篇文章希望能对你有帮助。
一、需求
1、业务需求:基于前后端不分离的前提,搭建一个简单的酒店后台管理系统,该系统需要在前端进行登录验证,后台管理界面只需要实现一个菜单的增删改查功能即可。
2:技术栈:
前端:view UI + axios(2.x以上的版本都可以)
后端:springboot+thymeleaf+shiro+mybatisplus
数据库:mysql
开发工具:IDEA(2018.03)
二、创建一个springboot空项目
使用spring initializr快速创建一个springboot项目(具体创建方法请自行百度)
注意:生成的项目结构目录中application默认是application.properties,但是我习惯改成application.yml来使用。
三、后端配置文件
1、准备pom.xml文件,导入相关的依赖
// An highlighted block
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--继承Springboot的默认父工程-->
<!--Springboot父工程-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.wande</groupId>
<artifactId>yxy</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>yxy</name>
<description>Demo project for Spring Boot</description>
<!--修改版本参数-->
<properties>
<java.version>1.8</java.version>
</properties>
<!--导入依赖-->
<dependencies>
<!--导入web支持:SpringMVC支持,Servlet相关的支持-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--热部署依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<!--<scope>runtime</scope>-->
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--shiro整合依赖-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-web-starter</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.shiro</