Bootstrap

整合shoir


目录

一、📢前言

二、📝SpringBoot整合Shiro

2.1 📲导入依赖


org.springframework.boot
spring-boot-starter-web

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.apache.shiro</groupId>
        <artifactId>shiro-spring</artifactId>
        <version>1.11.0</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </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>
</dependencies>

spring-boot-starter-web:提供Web应用程序所需的核心Spring Boot依赖项。
spring-boot-devtools:提供开发工具,例如自动重新加载和远程调试。
shiro-spring:提供Apache Shiro安全框架的Spring集成。
spring-boot-starter-thymeleaf:提供Thymeleaf模板引擎。
lombok:提供Java注解,简化了Java代码的编写。
spring-boot-starter-test:提供Spring Boot测试框架所需的依赖项。
2.2.🚩创建实体
   2.2.1 Permissions.java

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Permissions {
private String id;
private String permissionsName;
}
2.2.2.Role.java

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.Set;

@Data
@AllArgsConstructor
public class Role {

private String id;
private String roleName;
/**
 * 角色对应权限集合
 */
private Set<Permissions> permissions;

}

2.2.3. User.java

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.Set;

@Data
@AllArgsConstructor
public class User {
private String id;
private String userName;
private String password;
/**
* 用户对应的角色集合
/
private Set roles;
}
2.3 📌配置Shiro
/
*

  • Crea

;