欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SpringBoot中整合Shiro實(shí)現(xiàn)權(quán)限管理的示例代碼

 更新時間:2020年09月10日 10:27:12   作者:Asurplus、  
這篇文章主要介紹了SpringBoot中整合Shiro實(shí)現(xiàn)權(quán)限管理的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

之前在 SSM 項(xiàng)目中使用過 shiro,發(fā)現(xiàn) shiro 的權(quán)限管理做的真不錯,但是在 SSM 項(xiàng)目中的配置太繁雜了,于是這次在 SpringBoot 中使用了 shiro,下面一起看看吧

一、簡介

Apache Shiro是一個強(qiáng)大且易用的Java安全框架,執(zhí)行身份驗(yàn)證、授權(quán)、密碼和會話管理。使用Shiro的易于理解的API,您可以快速、輕松地獲得任何應(yīng)用程序,從最小的移動應(yīng)用程序到最大的網(wǎng)絡(luò)和企業(yè)應(yīng)用程序。

三個核心組件:

1、Subject

即“當(dāng)前操作用戶”。但是,在 Shiro 中,Subject 這一概念并不僅僅指人,也可以是第三方進(jìn)程、后臺帳戶(Daemon Account)或其他類似事物。它僅僅意味著“當(dāng)前跟軟件交互的東西”。Subject 代表了當(dāng)前用戶的安全操作,SecurityManager 則管理所有用戶的安全操作。

2、SecurityManager

它是Shiro 框架的核心,典型的 Facade 模式,Shiro 通過 SecurityManager 來管理內(nèi)部組件實(shí)例,并通過它來提供安全管理的各種服務(wù)。

3、Realm

Realm 充當(dāng)了 Shiro 與應(yīng)用安全數(shù)據(jù)間的“橋梁”或者“連接器”。也就是說,當(dāng)對用戶執(zhí)行認(rèn)證(登錄)和授權(quán)(訪問控制)驗(yàn)證時,Shiro 會從應(yīng)用配置的 Realm 中查找用戶及其權(quán)限信息。從這個意義上講,Realm 實(shí)質(zhì)上是一個安全相關(guān)的 DAO:它封裝了數(shù)據(jù)源的連接細(xì)節(jié),并在需要時將相關(guān)數(shù)據(jù)提供給 Shiro。當(dāng)配置 Shiro 時,你必須至少指定一個 Realm,用于認(rèn)證和(或)授權(quán)。配置多個 Realm 是可以的,但是至少需要一個。Shiro 內(nèi)置了可以連接大量安全數(shù)據(jù)源(又名目錄)的 Realm,如 LDAP、關(guān)系數(shù)據(jù)庫(JDBC)、類似 INI 的文本配置資源以及屬性文件等。如果缺省的 Realm 不能滿足需求,你還可以插入代表自定義數(shù)據(jù)源的自己的 Realm 實(shí)現(xiàn)。

二、整合 shiro

1、引入 maven 依賴

<!-- web支持 -->
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- thymeleaf 模板引擎 -->
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- Shiro 權(quán)限管理 -->
<dependency>
  <groupId>org.apache.shiro</groupId>
  <artifactId>shiro-spring</artifactId>
  <version>1.2.4</version>
</dependency>
<!-- 為了能夠在 html 中使用 shiro 的標(biāo)簽引入 -->
<dependency>
  <groupId>com.github.theborakompanioni</groupId>
  <artifactId>thymeleaf-extras-shiro</artifactId>
  <version>2.0.0</version>
</dependency>

我使用的 SpringBoot 版本是 2.3.1,其它依賴自己看著引入吧

2、創(chuàng)建 shiro 配置文件

關(guān)于 shiro 的配置信息,我們都放在 ShiroConfig.java 文件中

import at.pollux.thymeleaf.shiro.dialect.ShiroDialect;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
import org.apache.shiro.mgt.SecurityManager;
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.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * shiro配置類
 */
@Configuration
public class ShiroConfig {

  /**
   * 注入這個是是為了在thymeleaf中使用shiro的自定義tag。
   */
  @Bean(name = "shiroDialect")
  public ShiroDialect shiroDialect() {
    return new ShiroDialect();
  }

  /**
   * 地址過濾器
   * @param securityManager
   * @return
   */
  @Bean
  public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager) {
    ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
    // 設(shè)置securityManager
    shiroFilterFactoryBean.setSecurityManager(securityManager);
    // 設(shè)置登錄url
    shiroFilterFactoryBean.setLoginUrl("/login");
    // 設(shè)置主頁url
    shiroFilterFactoryBean.setSuccessUrl("/");
    // 設(shè)置未授權(quán)的url
    shiroFilterFactoryBean.setUnauthorizedUrl("/unauthorized");
    Map<String, String> filterChainDefinitionMap = new LinkedHashMap<>();
    // 開放登錄接口
    filterChainDefinitionMap.put("/doLogin", "anon");
    // 開放靜態(tài)資源文件
    filterChainDefinitionMap.put("/css/**", "anon");
    filterChainDefinitionMap.put("/img/**", "anon");
    filterChainDefinitionMap.put("/js/**", "anon");
    filterChainDefinitionMap.put("/layui/**", "anon");
    // 其余url全部攔截,必須放在最后
    filterChainDefinitionMap.put("/**", "authc");
    shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
    return shiroFilterFactoryBean;
  }

 /**
 * 自定義安全管理策略
 */
  @Bean
  public SecurityManager securityManager() {
    DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
    /**
     設(shè)置自定義的relam
     */
    securityManager.setRealm(loginRelam());
    return securityManager;
  }

 /**
 * 登錄驗(yàn)證
 */
  @Bean
  public LoginRelam loginRelam() {
    return new LoginRelam();
  }

  /**
   * 以下是為了能夠使用@RequiresPermission()等標(biāo)簽
   */
  @Bean
  @DependsOn({"lifecycleBeanPostProcessor"})
  public DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator() {
    DefaultAdvisorAutoProxyCreator advisorAutoProxyCreator = new DefaultAdvisorAutoProxyCreator();
    advisorAutoProxyCreator.setProxyTargetClass(true);
    return advisorAutoProxyCreator;
  }

  @Bean
  public static LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
    return new LifecycleBeanPostProcessor();
  }

  @Bean
  public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor() {
    AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
    authorizationAttributeSourceAdvisor.setSecurityManager(securityManager());
    return authorizationAttributeSourceAdvisor;
  }
}

上面開放靜態(tài)資源文件,其它博客說的是 **filterChainDefinitionMap.put("/static/**", "anon");** ,但我發(fā)現(xiàn),我們在 html 文件中引入靜態(tài)文件時,請求路徑根本沒有經(jīng)過 static,thymeleaf 自動默認(rèn)配置 **static/** 下面就是靜態(tài)資源文件,所以,我們開放靜態(tài)資源文件需要指定響應(yīng)的目錄路徑

2、登錄驗(yàn)證管理

關(guān)于登錄驗(yàn)證的一些邏輯,以及賦權(quán)等操作,我們都放在 LoginRelam.java 文件中

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zyxx.sbm.entity.UserInfo;
import com.zyxx.sbm.service.RolePermissionService;
import com.zyxx.sbm.service.UserInfoService;
import com.zyxx.sbm.service.UserRoleService;
import org.apache.shiro.authc.*;
import org.apache.shiro.authc.credential.CredentialsMatcher;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.util.ByteSource;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Set;

/**
 * 登錄授權(quán)
 */
public class LoginRelam extends AuthorizingRealm {

  @Autowired
  private UserInfoService userInfoService;
  @Autowired
  private UserRoleService userRoleService;
  @Autowired
  private RolePermissionService rolePermissionService;

  /**
   * 身份認(rèn)證
   *
   * @param authenticationToken
   * @return
   * @throws AuthenticationException
   */
  @Override
  protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
    // 獲取基于用戶名和密碼的令牌:實(shí)際上這個authcToken是從LoginController里面currentUser.login(token)傳過來的
    UsernamePasswordToken token = (UsernamePasswordToken) authenticationToken;

    //根據(jù)用戶名查找到用戶信息
    QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
    queryWrapper.eq("account", token.getUsername());
    UserInfo userInfo = userInfoService.getOne(queryWrapper);

    // 沒找到帳號
    if (null == userInfo) {
      throw new UnknownAccountException();
    }

    // 校驗(yàn)用戶狀態(tài)
    if ("1".equals(userInfo.getStatus())) {
      throw new DisabledAccountException();
    }

    // 認(rèn)證緩存信息
    return new SimpleAuthenticationInfo(userInfo, userInfo.getPassword(), ByteSource.Util.bytes(userInfo.getAccount()), getName());
  }

  /**
   * 角色授權(quán)
   *
   * @param principalCollection
   * @return
   */
  @Override
  protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {
    UserInfo authorizingUser = (UserInfo) principalCollection.getPrimaryPrincipal();
    if (null != authorizingUser) {
      //權(quán)限信息對象info,用來存放查出的用戶的所有的角色(role)及權(quán)限(permission)
      SimpleAuthorizationInfo simpleAuthorizationInfo = new SimpleAuthorizationInfo();

      //獲得用戶角色列表
      Set<String> roleSigns = userRoleService.listUserRoleByUserId(authorizingUser.getId());
      simpleAuthorizationInfo.addRoles(roleSigns);

      //獲得權(quán)限列表
      Set<String> permissionSigns = rolePermissionService.listRolePermissionByUserId(authorizingUser.getId());
      simpleAuthorizationInfo.addStringPermissions(permissionSigns);
      return simpleAuthorizationInfo;
    }
    return null;
  }

  /**
   * 自定義加密規(guī)則
   *
   * @param credentialsMatcher
   */
  @Override
  public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) {
    // 自定義認(rèn)證加密方式
    CustomCredentialsMatcher customCredentialsMatcher = new CustomCredentialsMatcher();
    // 設(shè)置自定義認(rèn)證加密方式
    super.setCredentialsMatcher(customCredentialsMatcher);
  }
}

以上就是登錄時,需要指明 shiro 對用戶的一些驗(yàn)證、授權(quán)等操作,還有自定義密碼驗(yàn)證規(guī)則,在第3步會講到,獲取角色列表,權(quán)限列表,需要獲取到角色與權(quán)限的標(biāo)識,每一個角色,每一個權(quán)限都有唯一的標(biāo)識,裝入 Set 中

3、自定義密碼驗(yàn)證規(guī)則

密碼的驗(yàn)證規(guī)則,我們放在了 CustomCredentialsMatcher.java 文件中

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;

/**
 * @ClassName CustomCredentialsMatcher
 * 自定義密碼加密規(guī)則
 * @Author Lizhou
 * @Date 2020-07-10 16:24:24
 **/
public class CustomCredentialsMatcher extends SimpleCredentialsMatcher {

  @Override
  public boolean doCredentialsMatch(AuthenticationToken authcToken, AuthenticationInfo info) {
    UsernamePasswordToken token = (UsernamePasswordToken) authcToken;
    //加密類型,密碼,鹽值,迭代次數(shù)
    Object tokenCredentials = new SimpleHash("md5", token.getPassword(), token.getUsername(), 6).toHex();
    // 數(shù)據(jù)庫存儲密碼
    Object accountCredentials = getCredentials(info);
    // 將密碼加密與系統(tǒng)加密后的密碼校驗(yàn),內(nèi)容一致就返回true,不一致就返回false
    return equals(tokenCredentials, accountCredentials);
  }
}

我們采用的密碼加密方式為 MD5 加密,加密 6 次,使用登錄賬戶作為加密密碼的鹽進(jìn)行加密

4、密碼加密工具

上面我們自定義了密碼加密規(guī)則,我們創(chuàng)建一個密碼加密的工具類 PasswordUtils.java 文件

import org.apache.shiro.crypto.hash.Md5Hash;


/**
 * 密碼加密的處理工具類
 */
public class PasswordUtils {

  /**
   * 迭代次數(shù)
   */
  private static final int ITERATIONS = 6;

  private PasswordUtils() {
    throw new AssertionError();
  }

  /**
   * 字符串加密函數(shù)MD5實(shí)現(xiàn)
   *
   * @param password 密碼
   * @param loginName 用戶名
   * @return
   */
  public static String getPassword(String password, String loginName) {
    return new Md5Hash(password, loginName, ITERATIONS).toString();
  }
}

三、開始登錄

上面,我們已經(jīng)配置了 shiro 的一系列操作,從登錄驗(yàn)證、密碼驗(yàn)證規(guī)則、用戶授權(quán)等等,下面我們就開始登錄,登錄的操作,放在了 LoginController.java 文件中

import com.zyxx.common.consts.SystemConst;
import com.zyxx.common.enums.StatusEnums;
import com.zyxx.common.kaptcha.KaptchaUtil;
import com.zyxx.common.shiro.SingletonLoginUtils;
import com.zyxx.common.utils.PasswordUtils;
import com.zyxx.common.utils.ResponseResult;
import com.zyxx.sbm.entity.UserInfo;
import com.zyxx.sbm.service.PermissionInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName LoginController
 * @Description
 * @Author Lizhou
 * @Date 2020-07-02 10:54:54
 **/
@Api(tags = "后臺管理端--登錄")
@Controller
public class LoginController {

  @Autowired
  private PermissionInfoService permissionInfoService;

  @ApiOperation(value = "請求登錄頁面", notes = "請求登錄頁面")
  @GetMapping("login")
  public String init() {
    return "login";
  }

  @ApiOperation(value = "請求主頁面", notes = "請求主頁面")
  @GetMapping("/")
  public String index() {
    return "index";
  }

  @ApiOperation(value = "登錄驗(yàn)證", notes = "登錄驗(yàn)證")
  @ApiImplicitParams({
      @ApiImplicitParam(name = "account", value = "賬號", required = true),
      @ApiImplicitParam(name = "password", value = "密碼", required = true),
      @ApiImplicitParam(name = "resCode", value = "驗(yàn)證碼", required = true),
      @ApiImplicitParam(name = "rememberMe", value = "記住登錄", required = true)
  })
  @PostMapping("doLogin")
  @ResponseBody
  public ResponseResult doLogin(String account, String password, String resCode, Boolean rememberMe, HttpServletRequest request, HttpServletResponse response) throws Exception {
    // 驗(yàn)證碼
    if (!KaptchaUtil.validate(resCode, request)) {
      return ResponseResult.getInstance().error(StatusEnums.KAPTCH_ERROR);
    }
    // 驗(yàn)證帳號和密碼
    Subject subject = SecurityUtils.getSubject();
    UsernamePasswordToken token = new UsernamePasswordToken(account, password);
    // 記住登錄狀態(tài)
    token.setRememberMe(rememberMe);
    try {
      // 執(zhí)行登錄
      subject.login(token);
      // 將用戶保存到session中
  UserInfo userInfo = (UserInfo) subject.getPrincipal();
      request.getSession().setAttribute(SystemConst.SYSTEM_USER_SESSION, userInfo);
      return ResponseResult.getInstance().success();
    } catch (UnknownAccountException e) {
      return ResponseResult.getInstance().error("賬戶不存在");
    } catch (DisabledAccountException e) {
      return ResponseResult.getInstance().error("賬戶已被凍結(jié)");
    } catch (IncorrectCredentialsException e) {
      return ResponseResult.getInstance().error("密碼不正確");
    } catch (ExcessiveAttemptsException e) {
      return ResponseResult.getInstance().error("密碼連續(xù)輸入錯誤超過5次,鎖定半小時");
    } catch (RuntimeException e) {
      return ResponseResult.getInstance().error("未知錯誤");
    }
  }

  @ApiOperation(value = "登錄成功,跳轉(zhuǎn)主頁面", notes = "登錄成功,跳轉(zhuǎn)主頁面")
  @PostMapping("success")
  public String success() {
    return "redirect:/";
  }

  @ApiOperation(value = "初始化菜單數(shù)據(jù)", notes = "初始化菜單數(shù)據(jù)")
  @GetMapping("initMenu")
  @ResponseBody
  public String initMenu() {
    return permissionInfoService.initMenu();
  }

  @ApiOperation(value = "退出登錄", notes = "退出登錄")
  @GetMapping(value = "loginOut")
  public String logout() {
    Subject subject = SecurityUtils.getSubject();
    subject.logout();
    return "login";
  }
}

 當(dāng)執(zhí)行 subject.login(token); 時,就會進(jìn)入我們在 第二步中第二條登錄驗(yàn)證中,對用戶密碼、狀態(tài)進(jìn)行檢查,對用戶授權(quán)等操作,登錄的密碼,一定是通過密碼加密工具得到的,不然驗(yàn)證不通過

四、頁面權(quán)限控制

我們本次使用的是 thymeleaf 模板引擎,我們需要在 html 文件中加入以下內(nèi)容

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">

 引入了 thymeleaf 的依賴,以及 shiro 的依賴,這樣我們就能在 html 文件中使用 thymeleaf、shiro 的標(biāo)簽了

例如:

1、判斷當(dāng)前用戶有無此權(quán)限,通過權(quán)限標(biāo)識

<button class="layui-btn" shiro:hasPermission="user_info_add"><i class="layui-icon">&#xe654;</i> 新增 </button> 

2、與上面相反,判斷當(dāng)前用戶無此權(quán)限,通過權(quán)限標(biāo)識,沒有時驗(yàn)證通過

<button class="layui-btn" shiro:lacksPermission="user_info_add"><i class="layui-icon">&#xe654;</i> 新增 </button> 

3、判斷當(dāng)前用戶有無以下全部權(quán)限,通過權(quán)限標(biāo)識

<button class="layui-btn" shiro:hasAllPermissions="user_info_add"><i class="layui-icon">&#xe654;</i> 新增 </button>

4、判斷當(dāng)前用戶有無以下任一權(quán)限,通過權(quán)限標(biāo)識

<button class="layui-btn" shiro:hasAnyPermissions="user_info_add"><i class="layui-icon">&#xe654;</i> 新增 </button>

5、判斷當(dāng)前用戶有無此角色,通過角色標(biāo)識

<a shiro:hasRole="admin" href="admin.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Administer the system</a>

6、與上面相反,判斷當(dāng)前用戶無此角色,通過角色標(biāo)識,沒有時驗(yàn)證通過

<a shiro:lacksRole="admin" href="admin.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Administer the system</a>

7、判斷當(dāng)前用戶有無以下全部角色,通過角色標(biāo)識

<a shiro:hasAllRoles="admin,role1,role2" href="admin.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Administer the system</a>

8、判斷當(dāng)前用戶有無以下任一角色,通過角色標(biāo)識

<a shiro:hasAnyRoles="admin,role1,role2" href="admin.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Administer the system</a>

到此這篇關(guān)于SpringBoot中整合Shiro實(shí)現(xiàn)權(quán)限管理的示例代碼的文章就介紹到這了,更多相關(guān)SpringBoot整合Shiro權(quán)限內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 一文詳解Spring是怎么讀取配置Xml文件的

    一文詳解Spring是怎么讀取配置Xml文件的

    這篇文章主要介紹了一文詳解Spring是怎么讀取配置Xml文件的,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價值,感興趣的小伙伴可以參考一下
    2022-08-08
  • Java排序算法之選擇排序代碼實(shí)例

    Java排序算法之選擇排序代碼實(shí)例

    這篇文章主要介紹了Java排序算法之選擇排序代碼實(shí)例,從數(shù)組的第一個元素開始,每次遍歷數(shù)組找出一個最小值放在最左側(cè),第二次從第二個元素開始,依次類推,直到起始元素為數(shù)組的倒數(shù)第二個元素時,直接和最后一個元素比較,較小值放左邊,完成排序,需要的朋友可以參考下
    2023-11-11
  • 關(guān)于springboot整合swagger問題及解決方法

    關(guān)于springboot整合swagger問題及解決方法

    這篇文章主要介紹了關(guān)于springboot整合swagger問題及解決方法,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-04-04
  • Java圖像處理之RGB調(diào)色面板

    Java圖像處理之RGB調(diào)色面板

    這篇文章主要為大家詳細(xì)介紹了Java圖像處理之RGB調(diào)色面板,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • 關(guān)于Java中阻塞隊(duì)列BlockingQueue的詳解

    關(guān)于Java中阻塞隊(duì)列BlockingQueue的詳解

    這篇文章主要介紹了關(guān)于Java中阻塞隊(duì)列BlockingQueue的詳解,BlockingQueue是為了解決多線程中數(shù)據(jù)高效安全傳輸而提出的,從阻塞這個詞可以看出,在某些情況下對阻塞隊(duì)列的訪問可能會造成阻塞,需要的朋友可以參考下
    2023-05-05
  • Java String創(chuàng)建對象實(shí)例解析

    Java String創(chuàng)建對象實(shí)例解析

    這篇文章主要介紹了Java String創(chuàng)建對象實(shí)例解析,分享了相關(guān)代碼示例,小編覺得還是挺不錯的,具有一定借鑒價值,需要的朋友可以參考下
    2018-02-02
  • java并發(fā)之ArrayBlockingQueue詳細(xì)介紹

    java并發(fā)之ArrayBlockingQueue詳細(xì)介紹

    這篇文章主要介紹了java并發(fā)之ArrayBlockingQueue詳細(xì)介紹的相關(guān)資料,需要的朋友可以參考下
    2017-05-05
  • SpringAOP中的切點(diǎn)表達(dá)式Pointcut詳解

    SpringAOP中的切點(diǎn)表達(dá)式Pointcut詳解

    這篇文章主要介紹了SpringAOP中的切點(diǎn)表達(dá)式Pointcut詳解,Spring?的?AOP?中的一個核心概念是切點(diǎn)(Pointcut),切點(diǎn)表達(dá)式定義通知(Advice)執(zhí)行的范圍,需要的朋友可以參考下
    2023-08-08
  • 如何把spring boot應(yīng)用發(fā)布到Harbor

    如何把spring boot應(yīng)用發(fā)布到Harbor

    這篇文章主要介紹了如何把spring boot應(yīng)用發(fā)布到Harbor,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2019-11-11
  • Java 8中字符串拼接新姿勢StringJoiner詳解

    Java 8中字符串拼接新姿勢StringJoiner詳解

    在本篇文章里小編給大家整理了關(guān)于Java 8中字符串拼接新姿勢StringJoiner的詳解內(nèi)容,需要的朋友們參考下。
    2019-09-09

最新評論