Spring boot与shiro集合实现权限管理

一.数据库表设计

表中的测试数据:

tb_user表如下,

 

pass_word是根据通过如下代码生成,根据用户名和密码生成md5值:

import org.apache.shiro.crypto.hash.SimpleHash;
import
org.apache.shiro.util.ByteSource;

public class
GenePd {
   
public static void main(String[] args) {
        String hashAlgorithName =
"MD5";
       
String password = "123456";
        int
hashIterations = 1024;//加密次数
       
ByteSource credentialsSalt = ByteSource.Util.bytes("admin");
       
Object obj = new SimpleHash(hashAlgorithName, password, credentialsSalt, hashIterations);
       
System.out.println(obj);
   
}
}

tb_role表如下:

 

tb_permission表如下:

 

tb_rp_relation表如下(tb_role与tb_permission的关联关系):

 

tb_ru_relation表如下(tb_role与tb_user的关联关系):

 

二、pom.xml文件中添加依赖(下面是我工程里填加的内容,可以根据自己项目只填加shiro部分内容):

<dependencies>

    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-web</artifactId>

    </dependency>



    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter</artifactId>

    </dependency>



    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-freemarker</artifactId>

    </dependency>

    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-test</artifactId>

        <scope>test</scope>

    </dependency>

     <!--junit测试依赖-->

    <dependency>

        <groupId>org.springframework</groupId>

        <artifactId>spring-test</artifactId>

        <version>4.3.5.RELEASE</version>

    </dependency>

    <dependency>

        <groupId>junit</groupId>

        <artifactId>junit</artifactId>

        <version> 4.12</version>

    </dependency>

    <dependency>

        <groupId>org.mybatis.spring.boot</groupId>

        <artifactId>mybatis-spring-boot-starter</artifactId>

        <version>1.3.1</version>

    </dependency>

    <dependency>

        <groupId>mysql</groupId>

        <artifactId>mysql-connector-java</artifactId>

        <scope>runtime</scope>

    </dependency>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值