Spring Boot整合shiro

Spring Boot整合Shiro 记录一次简单易懂的Spring Boot整合Shiro的过程,实现用户认证、授权、密码加密、权限管理功能。 阅读详情

shiro面世已经有很长时间了,相比Spring security更加精简一些,也更容易上手,因此就想分享下这段时间的学习成果,就当是学习笔记了

1 pom文件如下

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>net.axcf</groupId>
  <artifactId>ShiroSample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>ShiroSample</name>
  <url>http://maven.apache.org</url>
  
  

  <properties>
    	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<java.version>1.8</java.version>
  </properties>
  <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.6.RELEASE</version>
  </parent>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    
    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
           
        </dependency>
        <dependency>
		<groupId>org.mybatis.spring.boot</groupId>
		<artifactId>mybatis-spring-boot-starter</artifactId>
		<version>1.3.1</version>
	</dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
            
        </dependency>
       <dependency>
	   <groupId>mysql</groupId>
	   <artifactId>mysql-connector-java</artifactId>
	   <version>5.1.46</version>
	</dependency>
         <dependency>  
            <groupId>org.apache.shiro</groupId>  
            <artifactId>shiro-core</artifactId>  
            <version>1.3.2</version>  
        </dependency> 
       <dependency>
           <groupId>org.apache.shiro</groupId>
           <artifactId>shiro-spring</artifactId>
           <version>1.3.2</version>
       </dependency>
        <!-- shiro ehcache -->
       <dependency>
           <groupId>org.apache.shiro</groupId>
           <artifactId>shiro-ehcache</artifactId>
           <version>1.3.2</version>
       </dependency>
       <dependency>
	  <groupId>org.springframework.boot</groupId>
	  <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
    <!-- servlet依赖. -->
     <dependency>
	<groupId>javax.servlet</groupId>
	<artifactId>javax.servlet-api</artifactId>
	<scope>provided</scope>
      </dependency>
		
      <dependency>
	<groupId>javax.servlet</groupId>
	<artifactId>jstl</artifactId>
       </dependency>
      <!-- tomcat的支持.-->
	<dependency>
	  <groupId>org.springframework.boot</groupId>
	  <artifactId>spring-boot-starter-tomcat</artifactId>
	   <scope>provided</scope>
	</dependency>
	<dependency>
	    <groupId>org.apache.tomcat.embed</groupId>
	    <artifactId>tomcat-embed-jasper</artifactId>
	    <!--<scope>provided</scope>-->
	</dependency>
	<dependency>
	   <groupId>net.mingsoft</groupId>
           <artifactId>shiro-freemarker-tags</artifactId>
            <version>1.0.0</version>
       </dependency>

  </dependencies>
  
</project>

2  下面介绍shiro比较重要的Realm,先上代码

package com.debug.shiro;

import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import javax.annotation.Resource;

import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.SimpleAuthenticationInfo;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;

import com.debug.dto.UserAuthInfo;
import com.debug.entity.user.User;
import com.debug.service.UserService;

public class MyShiroRealm extends AuthorizingRealm{
     
	@Resource
	private UserService userService;
	
	/* 
	 * 授权
	 */
	protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
		Object principal=principals.getPrimaryPrincipal();
		
		Set<String> roleSet=new HashSet<String>();
		 //添加角色和权限
                SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo();
        
                 //获取用户对应的权限
                List<UserAuthInfo> auth=userService.findUserAuth(principal.toString());
                Iterator<UserAuthInfo> it=auth.iterator();
                Iterator<UserAuthInfo> permission=auth.iterator();
        
                while(it.hasNext()) {
        	    UserAuthInfo info=it.next();
        	    //添加角色
        	    simpleAuthorizationInfo.addRole(info.getRname());
        	    //添加权限
        	    while(permission.hasNext()) {
        		UserAuthInfo pinfo=permission.next();
        		simpleAuthorizationInfo.addStringPermission(pinfo.getMname());
        	     }
                }
		return simpleAuthorizationInfo;
	}

	
	/* 
	 * 认证
	 */
	protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
		UsernamePasswordToken utoken=(UsernamePasswordToken)token;
		String userName=utoken.getUsername();
		User u=userService.findByUserName(userName);
		
		ByteSource salt=ByteSource.Util.bytes(userName);
		if(u==null) {
			return null;
		}else {
			 //SimpleAuthenticationInfo simpleAuthenticationInfo = new SimpleAuthenticationInfo(userName, u.getPassword().toString(), getName());
			SimpleAuthenticationInfo simpleAuthenticationInfo=new SimpleAuthenticationInfo(userName, u.getPassword(), salt, this.getName());
			return simpleAuthenticationInfo;
		}
		
	}
	
	public Object getHashedCredential(String pswd) {
		String algorithmName="MD5";
		Object password=pswd;
		int hashIterations=1024;
		ByteSource salt=ByteSource.Util.bytes("guest");
		Object res=new SimpleHash(algorithmName, password, salt, hashIterations);
		return res;
	}

}

上面的2个方法是核心部分,这里把用户、角色、权限放到了mysql中,主要涉及到五张表:用户表,角色表(用户所拥有的角色),权限表(角色所涉及到的权限),用户-角色表(用户和角色是多对多的),角色-权限表(角色和权限是多对多的),表设计可以参考这里:https://www.cnblogs.com/hlhdidi/p/6376457.html

这里使用的是mybatis所以把主要的sql贴出来给大家:

<?xml version="1.0" encoding="UTF-8" ?>  
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >  
<mapper namespace="com.debug.dao.UserDao" >  
        <resultMap id="BaseResultMap" type="com.debug.entity.user.User" >  
                    <id column="uid" property="uid"  />
		    <result column="username" property="username" />
		    <result column="password" property="password" />
        </resultMap>  
        
         <resultMap id="authResultMap" type="com.debug.dto.UserAuthInfo" >  
                    <id column="uid" property="uid"  />
		    <result column="username" property="username" />
		    <result column="password" property="password" />
		    <result column="mid" property="mid" />
		    <result column="mname" property="mname" />
        </resultMap>  
     
      <select id="findByUserName" parameterType="string" resultType="com.debug.entity.user.User">
      
        select * from user where username=#{userName}
      </select>
      
      <select id="findUserAuth" parameterType="string" resultMap="authResultMap">
        select A.*,B.rid,B.rname,C.mid,C.mname from user A,role B,module C,module_role D,user_role E 
        where A.uid=E.uid and B.rid=E.rid and B.rid=D.rid and C.mid=D.mid and D.rid=B.rid
        and A.username=#{username}
      </select>
</mapper>  

这次重点放在shiro上,其他技术不做详细讨论

3 凭证比对器(按需编写,可加入盐值加密)

package com.debug.shiro;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class MyCredentialsMatcher extends SimpleCredentialsMatcher{
	public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
		
        UsernamePasswordToken utoken=(UsernamePasswordToken) token;
        //获得用户输入的用户名、密码:(采用加盐(salt)的方式去检验)
        String userName = new String(utoken.getUsername());
        String password = new String(utoken.getPassword());
        
        //获得数据库中的密码
        String dbPassword=(String) info.getCredentials();
        
        ByteSource salt=ByteSource.Util.bytes(userName);
	Object res=new SimpleHash("MD5", password, salt, 1024);
		
	if(res.toString().equals(dbPassword)) {
	    return true;
	}else {
	   return false;
	}
        
        //进行密码的比对
        //return this.equals(inPassword, dbPassword);
    }
}

盐值根据需要选择可以是id,userName或者其他,加密方式可以是MD5或者SHA1,只要shiro支持即可,加密次数加上比较好

4 把shiro的所有配置 配置给spring boot

package com.debug.config;

import java.util.*;

import org.apache.shiro.authc.credential.CredentialsMatcher;
import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.apache.shiro.mgt.SecurityManager;

import com.debug.shiro.MyCredentialsMatcher;
import com.debug.shiro.MyShiroRealm;

@Configuration
public class ShiroConfiguration {
	   @Bean(name="shiroFilter")
	    public ShiroFilterFactoryBean shiroFilter(@Qualifier("securityManager") SecurityManager manager) {
	        ShiroFilterFactoryBean bean=new ShiroFilterFactoryBean();
	        bean.setSecurityManager(manager);
	        //配置登录的url和登录成功的url
	        bean.setLoginUrl("/auth/toLogin");
	        bean.setSuccessUrl("/auth/index");
	        //配置访问权限
	        LinkedHashMap<String, String> filterChainDefinitionMap=new LinkedHashMap<String, String>();
	        filterChainDefinitionMap.put("/auth/toLogin", "anon"); //表示可以匿名访问
	        filterChainDefinitionMap.put("/auth/loginCheck", "anon"); //表示可以匿名访问
	        filterChainDefinitionMap.put("/auth/logout","logout");
	        filterChainDefinitionMap.put("/**", "authc");//表示需要认证才可以访问
	        
	        bean.setFilterChainDefinitionMap(filterChainDefinitionMap);
	        return bean;
	    }
	    //配置核心安全事务管理器
	    @Bean(name="securityManager")
	    public SecurityManager securityManager(@Qualifier("authRealm") MyShiroRealm authRealm) {
	        System.err.println("--------------shiro已经加载----------------");
	        DefaultWebSecurityManager manager=new DefaultWebSecurityManager();
	        manager.setRealm(authRealm);
	        return manager;
	    }
	    //配置自定义的权限登录器
	    @Bean(name="authRealm")
	    public MyShiroRealm authRealm(@Qualifier("credentialsMatcher") CredentialsMatcher matcher) {
	    	MyShiroRealm authRealm=new MyShiroRealm();
	        authRealm.setCredentialsMatcher(matcher);
	        return authRealm;
	    }
	    //配置自定义的密码比较器
	    @Bean(name="credentialsMatcher")
	    public CredentialsMatcher credentialsMatcher() {
	        return new MyCredentialsMatcher();
	    }
	    @Bean
	    public LifecycleBeanPostProcessor lifecycleBeanPostProcessor(){
	        return new LifecycleBeanPostProcessor();
	    }
	    @Bean
	    public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator(){
	        DefaultAdvisorAutoProxyCreator creator=new DefaultAdvisorAutoProxyCreator();
	        creator.setProxyTargetClass(true);
	        return creator;
	    }
	    @Bean
	    public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(@Qualifier("securityManager") SecurityManager manager) {
	        AuthorizationAttributeSourceAdvisor advisor=new AuthorizationAttributeSourceAdvisor();
	        advisor.setSecurityManager(manager);
	        return advisor;
	    }
}

到这里主要的代码就写好了,下面就是页面,controller了

5 编写controller和jsp

package com.debug.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;


@Controller
@RequestMapping("/auth")
public class AuthController {
	
   @RequestMapping("/toLogin")
   public String  toLogin() {
	  
	   return "login";
   }
   @RequestMapping("/loginCheck")
   public String  loginCheck(@RequestParam("userName")String userName,@RequestParam("password")String password) {
	   int flag=0;
	   //获取subject
       Subject currentUser = SecurityUtils.getSubject();
       UsernamePasswordToken token = new UsernamePasswordToken(userName, password);
       token.setRememberMe(true);
       try {
          currentUser.login(token);
       }catch (AuthenticationException ae) {
    	   flag++;
    	  System.out.println("登录失败:"+ae.getMessage());
       }
       if(flag>0) {
    	   return "unauthorized";
       }else {
    	   return "index";
       }
	  
   }
   @RequestMapping("/index")
   public String  index() {
	  
	   return "index";
   }
   
   @RequestMapping("/unauthorized")
   public String  unauthorized() {
	   
	   return "unauthorized";
   }
   
   @RequestMapping("/user")
   public String  user() {
	   
	   return "user";
   }
   
   @RequestMapping("/admin")
   public String  admin() {
	   
	   return "admin";
   }
}

登录页面的jsp代码如下:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录页</title>
</head>
<body>
  <p>登录页</p>
  <form action="../auth/loginCheck" method="post">
          用户名:<input type="text" name="userName" /><br></br>
          密码:<input type="password" name="password" /><br></br>
          <input type="submit" value="提交"/>
   </form>
</body>
</html>

登录/授权成功后的页面index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>认证成功页</title>
</head>
<body>
  认证成功页<br><br>
  当前登录的用户是:<shiro:principal></shiro:principal><br><br>
  <shiro:hasPermission name="add">
    add功能<br><br>
  </shiro:hasPermission>
   <shiro:hasPermission name="delete">
   delete功能<br><br>
  </shiro:hasPermission>
   <shiro:hasPermission name="query">
   select功能<br><br>
  </shiro:hasPermission>
   <shiro:hasPermission name="update">
     update功能<br><br>
  </shiro:hasPermission>
  <a href="../auth/logout">登出</a>
</body>
</html>

其他页面随大家发挥,就不贴出来了,截图随后补上




注:

1 有关shiro里的session和web里的HttpSession大部分会有误解,它们并不冲突Controller里还是使用HttpSession,shiro的session则用在DAO或service层较好,session里的内容都是一样的,只是要注意适用范围

2 spring boot如果使用jsp作为视图解析器,要注意文件的存在位置,需要在src/main/下面建名为webapp的文件夹,里面放一层WEB-INF,下面才放jsp文件(夹)

##jsp##
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

这个配置不能错,否则容易出现404,如果是freemarker则直接在src/main下面建ftl的文件夹即可

3 为了在ftl中很好的使用shiro标签,还需要如下的配置

package com.debug.config;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

import com.jagregory.shiro.freemarker.ShiroTags;

import freemarker.template.TemplateModelException;

@Component
public class ShiroTagsFreeMarkerCfg {
	@Autowired
	private FreeMarkerConfigurer freeMarkerConfigurer;
	@PostConstruct
	public void setSharedVariable() throws TemplateModelException {  
		freeMarkerConfigurer.getConfiguration().setSharedVariable("shiro", new ShiroTags());  
		freeMarkerConfigurer.getConfiguration().setNumberFormat("#");
	}  
}

以上就是分享内容了,下次打算把shiro的学习demo分享一下,持续学习中..........生气


SpringBoot之整合Shiro(最详细) pom.xml 2.3 创建前端页面 在webapp文件夹中创建index.jsp和login.jsp index.jsp login.jsp 2.4 配置视图信息 application.properties 2.5 解决IDEA冲突问题 JSP 与IDEA 与SpringBoot存在一定的不兼容,修改此配置即可解决 pom.xml 3.2 自定义Realm 在shiro文件夹下创建realm文件夹 3.3 Shiro配置 在config文件夹中创建ShiroConfig.java 3.4 启动测试 输入 阅读详情

相关推荐

Spring Boot整合Shiro两种详细方法

在 Spring Boot 中做权限管理,一般来说,主流的方案是 Spring Security ,但是,仅仅从技术角度来说,也可以使用 Shiro。 Spring Security 和 Shiro 的比较: Spring Security 是一个重量级的安全管理框架;Shiro 则是一个轻量级的安全管理框架 Spring Security 概念复杂,配置繁琐;Shiro 概念简单、配置简单 S...

qianlia的博客 1841

SpringBoot与Shiro整合

本文章介绍了Spring boot下shiro与thymeleaf、mybatis的整合过程,Apache Shiro是一个强大且易用的Java安全框架,执行身份验证、授权、密码和会话管理

fangliangke的博客 6521

spring boot整合redis,实现shiro的CacheManager

接着上一篇博客来讲:Spring Boot整合jpa,Shiro进行权限管理 Shiro默认整合了EhCache,来实现缓存,如果我们想用redis替换EhCache来实现缓存怎么做了?我们可以从Shiro的源码来找到一些端倪。我们可以模拟EhCacheManager的实现方式,EhCacheManager类定义如下: public class EhCacheManager implement

牛奋lch 1万+

springBoot整合Shiro(详细教程分析)

🚩1.1 什么是ShiroShiro是一个开源的Java安全框架,它提供了身份认证、授权、加密和会话管理等功能,可以帮助我们快速地构建安全可靠的应用程序。🚩1.2 为什么要用Shiro在开发Web应用程序时,安全性是一个非常重要的问题。使用Shiro可以帮助我们快速地构建安全可靠的应用程序,而且Shiro的使用非常灵活,可以根据我们的需求进行定制。

ggjklncffd的博客 6383

Spring Boot 整合 Shiro 实现 Token 的登录和认证

Spring Boot 2.X 实战--Shiro (Token)登录和验证 主要介绍了 Spring Boot 整合 Spring Security 实现 Token 的登录和认证,这一小节中,我们将实现 Spring Boot 整合 Shiro 实现 Token 的登录和认证。 目录结构 1)Apache Shiro 简介 2)Shiro 项目配置 2.1)项目配置 3)开始...

u011202388的博客 6415

SpringBoot整合Shiro

Shiro简介   Apache Shiro是一个开源的轻量级的Java安全框架,它提供了身份认证、授权、密码管理、会话管理等操作。我们知道在Spring中也有一个跟它功能差不多的框架Spring Security,Shiro框架可以更加直观的提供安全性操作,在SSM框架中整合Shrio的配置步骤比较多。但是争对SpringBoot,在SpringBoot官方也提供了对应的启动器。这样的话化简了S...

初学者 2705

Springboot整合shiro

是一款主流的Java安全框架,不依赖任何容器,可以运行在Java SE和Java EE项目中,它的主要作用是对访问系统的用户进行身份认证、授权、会话管理、加密等操作。Shiro 就是用来解决安全管理的系统化框架。Shiro是基于session的身份认证和访问控制框架。RBAC是Role-Based Access Control(基于角色的访问控制)的缩写。它是一种广泛应用于安全管理中的访问控制模型。RBAC模型通过授予用户不同的角色,并将角色与权限进行关联,来管理对资源的访问。

chao的博客 2797

Spring Boot与Shiro整合全面指南

本文还有配套的精品资源,点击获取 简介:本指南详细介绍了如何将Apache Shiro安全框架与Spring Boot相结合,实现完整的权限管理和用户认证授权功能。通过整合步骤的详细说明,包括依赖引入、配置、编码实现认证授权逻辑、安全管理器配置以及前端集成等,旨在帮助开发者快速构建安全且高效的应用程序。文章还涵盖了认证流程、授权流程、异常处理、会话管理以及数据库设计等关键点...

weixin_35755640的博客 1543

Spring Boot 整合 Shiro详解

创建一个自定义Realm类,用于实现用户认证和授权的逻辑:java复制import orgthrow new UnknownAccountException("用户不存在");} }throw new UnknownAccountException("用户不存在");} }throw new UnknownAccountException("用户不存在");

ning的博客 2346

从 0 到 1 构建 Graph RAG 系统:本地图谱 + 通义千问落地实践

本文介绍了一个基于知识图谱的检索增强生成系统(Graph RAG),该系统结合领域知识图谱、语义检索和大模型问答,旨在提供结构化、精准的技术问答服务。文章详细说明了项目背景、目标、核心技术架构以及实现方法,包括本地图谱构建、Neo4j数据库接入、语义检索和大模型集成等关键环节。该系统支持混合检索、多轮问答和知识图谱关联理解,能够有效减少大模型幻觉,提升问答的准确性和可解释性。文中还展示了核心代码结构和流程图,呈现了从文档加载到图谱构建再到问答生成的完整流程。该系统适用于需要处理复杂领域知识的研发和数据分析场

m0_58378112的博客 1399

AutoCAD 2025在Win10/Win11上的官方安装、配置与问题排查全指南

对于需要在 Windows 11 或 Windows 10 系统上部署 AutoCAD 2025 的设计师、工程师和 IT 支持人员来说,一个稳定、合规的安装流程是高效工作的基石。网络上充斥着各种所谓的“免费下载”和“一键安装”教程,但这些资源往往来源不明,可能捆绑恶意软件、导致软件崩溃,甚至引发严重的许可合规风险。本文旨在提供一个清晰、安全、基于官方最佳实践的 AutoCAD 2025 安装与配置指南,重点解决在 Windows 11 和 Windows 10 系统上部署时可能遇到的兼容性问题、安装失败以

weixin_34396103的博客 448

Spring Boot整合Shiro教程

Spring Boot整合Shiro教程 项目介绍 本项目是一个基于Spring Boot和Apache Shiro的安全框架整合示例。Apache Shiro是一个强大且灵活的开源安全框架,用于身份认证、授权、会话管理和加密。Spring Boot则是一个用于简化Spring应用初始搭建以及开发过程的框架。通过将两者结合,可以快速构建一个具备安全认证和授权功能的企业级应用。 项目快速启动 1. ...

gitblog_00326的博客 958

YOLO26涨点改进 | 全网独家复现、小目标检测改进篇 | TGRS 2025 | YOLO26引入MFAE-YOLO中的GFFP、FCPS 和 C3k2-FPEU创新点,涨点起飞,直接发论文

🔥本文给大家介绍在YOLO26中引入MFAE-YOLO中的 GFFP(全局特征融合处理)、FCPS(特征通道像素注意力) 和 C3k2-FPEU(特征池提取单元) 二次创新改进模块,能显著提升对小目标的检测性能。GFFP通过多尺度特征融合增强全局上下文感知能力,有效提升小目标在复杂背景下的可辨性;FCPS融合通道、像素和空间注意力机制,增强了模型对关键细节和小区域特征的关注,提升检测精度;C2F-FPEU利用多种池化方式挖掘细节特征,优化浅层特征表示能力。三者协同提升了YOLO26在小目标检测中的鲁棒性。

Ai缝合怪、助力小伙伴高效发论文 305

spring boot整合shiro之shiro过滤器介绍

过滤器链条配置说明 1、一个URL可以配置多个Filter,使用逗号分隔 2、当设置多个过滤器时,全部验证通过,才视为通过 3、部分过滤器可指定参数,如perms,roles Shiro内置的FilterChain anon(org.apache.shiro.web.filter.authc.AnonymousFilter):例子/admins/**=anon 没有参数,表示可以匿...

无名剑 1万+

用 ABAP CDS 把树建起来:Hierarchy 的建模、调试与消费全流程

CDS Hierarchy 将树形数据结构作为一等公民引入 ABAP 开发,通过定义父子关联、根节点条件和兄弟排序规则,让数据库原生支持层级查询。相比传统递归处理方式,它能避免性能瓶颈,提供$node系统字段描述节点结构信息,并支持与SAP UI框架无缝集成。这种方法简化了组织架构、成本中心等业务场景的层级数据处理,使开发人员能够专注于业务逻辑而非底层实现。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 205

多源异构数据融合(Kaggle+Google Trends联合分析)

本文详细介绍了如何利用Python实现多源异构数据融合,以Kaggle电商销售数据与Google Trends搜索指数为例,展示了数据清洗、预处理、时间对齐、数据合并、相关性分析、回归建模和可视化全过程。数据预处理与内存优化通过分块加载、数据类型转换和缺失值处理,有效降低了大规模数据在内存中的占用,并确保数据质量。时间对齐与数据融合策略采用重采样与内连接方法对齐不同数据源的时间维度,实现了高质量数据的融合,为后续联合分析奠定基础。模型构建与分析。

闲人编程的博客 1015

spring boot 整合shiro

在上一个记录http://blog.youkuaiyun.com/oyh1203/article/details/72235915中初步搭建了一个springboot的项目,现在想将shiro也整合到项目中去,不多说,动手搞,项目结构如图其它shiro相关的实现类不贴了shiro配置信息都放到properties文件中文件内容如下[html] view plain copy#SHIRO登录成功的URL地址  ...

haylee的专栏 715

20、自定义用户窗体:从创建到使用

本文详细介绍了在Excel VBA中创建和使用自定义用户窗体的完整过程,涵盖从窗体设计、控件添加与属性设置,到事件处理程序编写及宏调用的各个环节。通过实际示例讲解了如何实现文本大小写转换和员工信息录入等功能,并深入解析了常用控件的属性与事件机制。同时提供了控件命名规范、快捷键使用、布局技巧等实用建议,帮助读者构建高效、交互性强的VBA用户界面。

h0i1j2k3l的博客 131

spring boot 使用thymeleaf 和shiro标签整合

百度了下,发现这类例子并不多,且尝试下发现并没有实现想要的效果,故自己捣腾,终于可以用了。 在pom.xml文件中添加如下依赖: com.github.theborakompanioni thymeleaf-extras-shiro 1.2.1 org.apache.shiro shiro-core

Wisteriapcp的博客 3112

Python 爬虫实战:爬取哔哩哔哩知识区,抓取高赞课程信息

哔哩哔哩(Bilibili)是一个广受欢迎的综合性视频社区,其中的知识区汇聚了大量优质的教育、科普、技术等课程内容。本文将指导读者如何使用 Python 爬虫技术从哔哩哔哩知识区抓取高赞课程信息,并进行数据分析。本文深入探究了利用 Python 爬虫技术从哔哩哔哩知识区抓取高赞课程信息的全流程。从前期的环境搭建、模拟登录,到核心的课程数据抓取、存储,再到后续的数据分析与可视化,都详细展开讲解并提供代码支持。通过此方法所获取的数据,能够助力创作者优化内容、用户发现优质课程、平台洞察用户需求。

u014481728的博客 1135

实战篇| app爬虫不用真机

之前写过一篇基于真机app爬虫《App爬虫实战篇-以华为真机手机爬取集换社的app为例》,如果大家有用真机爬虫的经历,会深刻认识到真的不方便,一是自己的手机,经常会被电话、微信等打断,二是闲置手机,面对小批量数据还能勉强,大批量爬虫,会导致成本指数级上升,并且控制起来相对麻烦。以下就是常见的模拟器。emulator -avd my_avd -no-snapshot-save # 启动时不保存 snapshot。emulator -avd my_avd -wipe-data # 清除数据(恢复到出厂)

youbingchen的博客 596

shiro与spring boot的整合

Shiro整合springboot 相关项目jar包 <dependencies> <!--shiro整合springboot--> <dependency> <groupId>org.apache.shiro</groupId> <artifactId>shiro-spring</artifactId> <version>1.7.0</version> </de

weixin_44983481的博客 135

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

apache shiro怎么升级_Spring Boot整合Shiro两种详细方法

在 Spring Boot 中做权限管理,一般来说,主流的方案是 Spring Security ,但是,仅仅从技术角度来说,也可以使用 Shiro。 Spring Security 和 Shiro 的比较: Spring Security 是一个重量级的安全管理框架;Shiro 则是一个轻量级的安全管理框架 Spring Security 概念复杂,配置繁琐;Shiro 概念简单、配置简单 Sp...

weixin_39788960的博客 1151

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

上一篇: Spring Boot整合MongoDB实现增删改查
下一篇: 将博客搬至优快云
青蛙小王子
博客等级 码龄16年 239粉丝 311原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值