Shiro初识
Shiro学习
Shiro学习 简介 Apache Shiro 是 Java 的一个安全框架。目前,使用 Apache Shiro 的人越来越多,因为它相当简单,对比 Spring Security,可能没有 Spring Security 做的功能强大,但是在实际工作时可能并不需要那么复杂的东西,所以使用小而简单的 Shiro 就足够了。对于它俩到底哪个好,这个不必纠结,能更简单的解决项目问题就好了。
概念 https://www.w3cschool.cn/shiro/co4m1if2.html 详细
使用 依赖 <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.3</version> </dependency> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-core</artifactId> <version>1.3.2</version> </dependency> 配置文件 [users] zhangsan=123456,admin lisi=123123,superadmin [roles] admin=product:create,product:delete,product:update,product:view public=product:view 读取配置类 //1.初始化SecurityManger安全管理器 DefaultSecurityManager sm = new DefaultSecurityManager(); //2.配置用户的权限信息到安全管理器中 Realm realm = new IniRealm("classpath:shrio.ini"); sm.setRealm(realm); //3.使用SecurityUtils将securityManager设置到运行环境中 SecurityUtils.setSecurityManager(sm); 因为没有slf4j的配置,运行控制台报出