首页 / 知识
SpringBoot之整合Shiro
2023-04-11 16:20:00

1.SpringBoot整合Shiro思路
2. 环境搭建
2.1 创建项目
2.2 引入依赖
pom.xml
<dependencies>
<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.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--引入Jsp依赖-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<!--jstl-->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
2.3 创建前端页面
在webapp文件夹中创建index.jsp和login.jsp
index.jsp
<%@page contentType="text/html;UTF-8" pageEncoding="UTF-8" isErrorPage="false" %>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<%--受限资源--%>
<h1>系统主页</h1>
<ul>
<li><a href="#">用户管理</a></li>
<li><a href="#">商品管理</a></li>
<li><a href="#">订单管理</a></li>
<li><a href="#">物流管理</a></li>
</ul>
</body>
</html>
login.jsp
<%@page contentType="text/html;UTF-8" pageEncoding="UTF-8" isErrorPage="false" %>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>登录界面</h1>
<form action="${pageContext.request.contextPath}/user/login" method="post">
用户名:<input type="text" name="username" > <br/>
密码 : <input type="text" name="password"> <br>
<input type="submit" value="登录">
</form>
</html>
2.4 配置视图信息
application.properties
server.port=8080
server.servlet.context-path=/shiro
spring.application.name=shiro
spring.mvc.view.prefix=/
spring.mvc.view.suffix=.jsp
2.5 解决IDEA冲突问题
JSP 与IDEA 与SpringBoot存在一定的不兼容,修改此配置即可解决
2.6 测试搭建的环境
3. 整合Shiro
3.1 引入依赖
pom.xml
<!--引入shrio-->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring-boot-starter</artifactId>
<version>1.5.3</version>
</dependency>
|
最新内容
相关内容
python 培训之 object是什么类型
python 培训之 object是什么类型,培训,类型,实例,顶端,对象,关系,链条,父子,数据类型,属性,在Python的世界中,object是父子关系的顶端,所有的数python版本2和3之间的区别是什么?
python版本2和3之间的区别是什么?,培训,区别,之间,版本,pythonHTTP与HTTPS之间的区别
pythonHTTP与HTTPS之间的区别,培训,区别,之间,python列表和元祖之间的区别
python列表和元祖之间的区别,数据,培训,设计,名字,类型,区别,同构,列表,不同点,操作,python列表和元组的区别如下相同点:都是序列类型回答它们python新手必看之文本文件的输入输
python新手必看之文本文件的输入输出,培训,标准,数据,文件,对象,输入输出,新手,模式,功能,内容,Python具有基本的文本文件读写功能。Python的Windows Vista和Visual Studio 200
Windows Vista和Visual Studio 2008之间的兼容性,Windows Vista和Visual Studio 2008之间的兼容性,运行,开发者,我想,一台,Compatabi如何在HTML select元素的选项文本
如何在HTML select元素的选项文本之前放置空格字符?,如何在HTML select元素的选项文本之前放置空格字符?,选项,我在,列表中,空格,How d关于算法:计算2个城市之间的距离
关于算法:计算2个城市之间的距离,关于算法:计算2个城市之间的距离,计算,您需要,地球,距离,Calculating Distance Between 2 Cities您如关于shell:是否有Unix实用程序在std
关于shell:是否有Unix实用程序在stdin之前添加时间戳?,关于shell:是否有Unix实用程序在stdin之前添加时间戳?,实用程序,脚本,输入,文本,I更改Ctrl + Tab行为以在Visual Stu
更改Ctrl + Tab行为以在Visual Studio中的文档之间移动,更改Ctrl + Tab行为以在Visual Studio中的文档之间移动,更改,方式,工作,Tab关于c#:在构造使用该数据的XmlReader
关于c#:在构造使用该数据的XmlReader或XPathDocument之前,如何从基于XML的数据源中删除无效的十六进制字符?,关于c#:在构造使用该数据的X关于sql:表扫描和聚集索引扫描之间
关于sql:表扫描和聚集索引扫描之间有什么区别?,关于sql:表扫描和聚集索引扫描之间有什么区别?,扫描,上都,实质,记录,What's the differe