最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信支付java版本之Native付款

 更新時(shí)間:2016年08月04日 14:19:28   作者:wangxuewei111  
這篇文章主要為大家詳細(xì)介紹了微信支付java版本之Native付款,感興趣的小伙伴們可以參考一下

最近工作中接觸到一些關(guān)于微信支付方面的東西,看到給的DEMO都是PHP版本的,再加上微信支付文檔寫的確實(shí)不敢恭維,趟過(guò)不少坑之后閑下來(lái)做個(gè)總結(jié)。

一、前期準(zhǔn)備 

做微信開發(fā)首先要申請(qǐng)一個(gè)公共賬號(hào),申請(qǐng)成功后會(huì)以郵件形式發(fā)給你一些必要信息,公共賬號(hào)中有開發(fā)文檔以及開發(fā)中必要信息,以及測(cè)試的數(shù)據(jù)查詢。

 

二、工具類
1.MD5加密工具類 

package com.pay.utils.weixin;
import java.security.MessageDigest;
public class MD5Util {
 public final static String MD5(String s) {
    char hexDigits[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};    
    try {
      byte[] btInput = s.getBytes();
      // 獲得MD5摘要算法的 MessageDigest 對(duì)象
      MessageDigest mdInst = MessageDigest.getInstance("MD5");
      // 使用指定的字節(jié)更新摘要
      mdInst.update(btInput);
      // 獲得密文
      byte[] md = mdInst.digest();
      // 把密文轉(zhuǎn)換成十六進(jìn)制的字符串形式
      int j = md.length;
      char str[] = new char[j * 2];
      int k = 0;
      for (int i = 0; i < j; i++) {
        byte byte0 = md[i];
        str[k++] = hexDigits[byte0 >>> 4 & 0xf];
        str[k++] = hexDigits[byte0 & 0xf];
      }
      return new String(str);
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
 }
}

2.CommonUtil工具類,用于裝換成微信所需XML。以下return new String(xml.toString().getBytes(),"ISO8859-1");將工具類中的utf-8改成iso8859-1,否則微信訂單中的中文會(huì)出現(xiàn)亂碼,改后可以正確顯示。 

package com.pay.utils.weixin;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import java.util.Map.Entry;

public class CommonUtil {

 public static String CreateNoncestr(int length) {
 String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
 String res = "";
 for (int i = 0; i < length; i++) {
  Random rd = new Random();
  res += chars.indexOf(rd.nextInt(chars.length() - 1));
 }
 return res;
 }

 public static String CreateNoncestr() {
 String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
 String res = "";
 for (int i = 0; i < 16; i++) {
  Random rd = new Random();
  res += chars.charAt(rd.nextInt(chars.length() - 1));
 }
 return res;
 }

 public static String FormatQueryParaMap(HashMap<String, String> parameters)
  throws SDKRuntimeException {

 String buff = "";
 try {
  List<Map.Entry<String, String>> infoIds = new ArrayList<Map.Entry<String, String>>(
   parameters.entrySet());

  Collections.sort(infoIds,
   new Comparator<Map.Entry<String, String>>() {
   public int compare(Map.Entry<String, String> o1,
    Map.Entry<String, String> o2) {
    return (o1.getKey()).toString().compareTo(
     o2.getKey());
   }
   });

  for (int i = 0; i < infoIds.size(); i++) {
  Map.Entry<String, String> item = infoIds.get(i);
  if (item.getKey() != "") {
   buff += item.getKey() + "="
    + URLEncoder.encode(item.getValue(), "utf-8") + "&";
  }
  }
  if (buff.isEmpty() == false) {
  buff = buff.substring(0, buff.length() - 1);
  }
 } catch (Exception e) {
  throw new SDKRuntimeException(e.getMessage());
 }

 return buff;
 }

 public static String FormatBizQueryParaMap(HashMap<String, String> paraMap,
  boolean urlencode) throws SDKRuntimeException {

 String buff = "";
 try {
  List<Map.Entry<String, String>> infoIds = new ArrayList<Map.Entry<String, String>>(
   paraMap.entrySet());

  Collections.sort(infoIds,
   new Comparator<Map.Entry<String, String>>() {
   public int compare(Map.Entry<String, String> o1,
    Map.Entry<String, String> o2) {
    return (o1.getKey()).toString().compareTo(
     o2.getKey());
   }
   });

  for (int i = 0; i < infoIds.size(); i++) {
  Map.Entry<String, String> item = infoIds.get(i);
  //System.out.println(item.getKey());
  if (item.getKey() != "") {
   
   String key = item.getKey();
   String val = item.getValue();
   if (urlencode) {
   val = URLEncoder.encode(val, "utf-8");

   }
   buff += key.toLowerCase() + "=" + val + "&";

  }
  }

  if (buff.isEmpty() == false) {
  buff = buff.substring(0, buff.length() - 1);
  }
 } catch (Exception e) {
  throw new SDKRuntimeException(e.getMessage());
 }
 return buff;
 }

 public static boolean IsNumeric(String str) {
 if (str.matches("\\d *")) {
  return true;
 } else {
  return false;
 }
 }

 public static String ArrayToXml(HashMap<String, String> arr) {
 String xml = "<xml>";
 
 Iterator<Entry<String, String>> iter = arr.entrySet().iterator();
 while (iter.hasNext()) {
  Entry<String, String> entry = iter.next();
  String key = entry.getKey();
  String val = entry.getValue();
  if (IsNumeric(val)) {
  xml += "<" + key + ">" + val + "</" + key + ">";

  } else
  xml += "<" + key + "><![CDATA[" + val + "]]></" + key + ">";
 }

 xml += "</xml>";
  try {
  return new String(xml.toString().getBytes(),"ISO8859-1");
 } catch (UnsupportedEncodingException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 } 
  return "";
 }

}

3.ClientCustomSSL工具類,用于生成sign以及創(chuàng)建微信訂單package com.pay.utils.weixin;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.util.StringUtils;


/**
 * This example demonstrates how to create secure connections with a custom SSL
 * context.
 */
public class ClientCustomSSL {

 public static String GetBizSign(HashMap<String, String> bizObj)
  throws SDKRuntimeException {
 HashMap<String, String> bizParameters = new HashMap<String, String>();

 List<Map.Entry<String, String>> infoIds = new ArrayList<Map.Entry<String, String>>(
  bizObj.entrySet());
 System.out.println(infoIds);
 Collections.sort(infoIds, new Comparator<Map.Entry<String, String>>() {
  public int compare(Map.Entry<String, String> o1,
   Map.Entry<String, String> o2) {
  return (o1.getKey()).toString().compareTo(o2.getKey());
  }
 });
System.out.println("--------------------");
 System.out.println(infoIds);
 for (int i = 0; i < infoIds.size(); i++) {
  Map.Entry<String, String> item = infoIds.get(i);
  if (item.getKey() != "") {
  bizParameters.put(item.getKey().toLowerCase(), item.getValue());
  }
 }
 //bizParameters.put("key", "12345678123456781234567812345671");
 String bizString = CommonUtil.FormatBizQueryParaMap(bizParameters,
  false);
 bizString += "&key=12345678123456781234567812345671";
 System.out.println("***************");
 
 System.out.println(bizString);

// return SHA1Util.Sha1(bizString);
 return MD5Util.MD5(bizString);

 }
 /**
 * 微信創(chuàng)建訂單
 * @param nonceStr
 * @param orderDescribe
 * @param orderNo
 * @param price
 * @param timeStart
 * @param timeExpire
 * @return
 * @throws SDKRuntimeException
 */
 public static String CreateNativePackage(String nonceStr,String orderDescribe,String orderNo,String price,String timeStart,String timeExpire) throws SDKRuntimeException {
 HashMap<String, String> nativeObj = new HashMap<String, String>();
 nativeObj.put("appid", "見公眾賬號(hào)");          //公眾賬號(hào)Id
 nativeObj.put("mch_id", "見郵件");    //商戶號(hào)
 nativeObj.put("nonce_str", nonceStr);       //隨機(jī)字符串
 nativeObj.put("body", orderDescribe);    //商品描述
 nativeObj.put("attach", "tradeno");    //附加數(shù)據(jù)
 nativeObj.put("out_trade_no", orderNo);          //商戶訂單號(hào)(全局唯一)
 nativeObj.put("total_fee", price);   //總金額(單位為分,不能帶小數(shù)點(diǎn))
 nativeObj.put("spbill_create_ip","192.168.0.144");     //終端Ip
 nativeObj.put("time_start", timeStart);          //交易起始時(shí)間
 nativeObj.put("time_expire", timeExpire);      //交易結(jié)束時(shí)間
 nativeObj.put("notify_url", CustomizedPropertyPlaceholderConfigurer.getContextProperty("wxurl")+"/weixin_callback/weixinCallback/init.action");                   //回調(diào)通知地址
 nativeObj.put("trade_type", "NATIVE");   //交易類型
 
 String sign = GetBizSign(nativeObj);
 
 nativeObj.put("sign", sign.toUpperCase());
 
 return CommonUtil.ArrayToXml(nativeObj);

 }       /**
* 微信訂單支付查詢
* @param nonceStr
* @param orderDescribe
* @param orderNo
* @param price
* @param timeStart
* @param timeExpire
* @return
* @throws SDKRuntimeException
*/
public static String SearchNativePackage(String transactionId,String outTradeNo,String nonceStr) throws SDKRuntimeException {
HashMap<String, String> nativeObj = new HashMap<String, String>();
nativeObj.put("appid", "見公眾共賬號(hào)"); //公眾賬號(hào)Id
nativeObj.put("mch_id", "見郵件");//商戶號(hào)
nativeObj.put("nonce_str", nonceStr);//隨機(jī)字符串
if(!StringUtils.isEmpty(transactionId)){
nativeObj.put("transaction_id", transactionId); 
}
if(!StringUtils.isEmpty(outTradeNo)){
nativeObj.put("out_trade_no", outTradeNo);//隨機(jī)字符串
}
String sign = GetBizSign(nativeObj);
nativeObj.put("sign", sign.toUpperCase()); 
return CommonUtil.ArrayToXml(nativeObj);
 /**
* 微信退款
* @param outTradeNo
* @param outRefundNo
 * @param totalFee
* @param refundFee
* @return
* @throws SDKRuntimeException
*/
public static String RefundNativePackage(String outTradeNo,String outRefundNo,String totalFee,String refundFee,String nonceStr) throws SDKRuntimeException {
HashMap<String, String> nativeObj = new HashMap<String, String>();
nativeObj.put("appid", "見公眾賬號(hào)");//公眾賬號(hào)Id
nativeObj.put("mch_id", "見郵件");//商戶號(hào)
nativeObj.put("nonce_str", nonceStr);//隨機(jī)字符串
nativeObj.put("out_trade_no", outTradeNo);//商戶訂單號(hào)(全局唯一)
nativeObj.put("out_refund_no", outRefundNo);//商戶退款單號(hào)(全局唯一)
nativeObj.put("total_fee", totalFee);//總金額(單位為分,不能帶小數(shù)點(diǎn))
nativeObj.put("refund_fee", refundFee);//退款金額(單位為分,不能帶小數(shù)點(diǎn))
nativeObj.put("op_user_id", "郵件");
String sign = GetBizSign(nativeObj);
nativeObj.put("sign", sign.toUpperCase());
return CommonUtil.ArrayToXml(nativeObj);
}

/**
* 微信待支付
 * @param nonceStr
* @param orderDescribe
* @param orderNo
* @param price
* @param timeStart
* @param timeExpire
* @return
* @throws SDKRuntimeException
*/
public static String CreateJsApiPackage(String nonceStr,String orderDescribe,String orderNo,String price,String timeStart,String timeExpire,String openId) throws SDKRuntimeException {
HashMap<String, String> nativeObj = new HashMap<String, String>();
nativeObj.put("appid", "見公眾賬號(hào)");//公眾賬號(hào)Id
nativeObj.put("openid", openId);//公眾賬號(hào)Id
nativeObj.put("mch_id", "見郵件")//商戶號(hào)
nativeObj.put("nonce_str", nonceStr);//隨機(jī)字符串
nativeObj.put("body", orderDescribe);//商品描述
nativeObj.put("attach", "tradeno");//附加數(shù)據(jù)
nativeObj.put("out_trade_no", orderNo);//商戶訂單號(hào)(全局唯一)
nativeObj.put("total_fee", price);//總金額(單位為分,不能帶小數(shù)點(diǎn))
nativeObj.put("spbill_create_ip","192.168.0.144");//終端Ip
nativeObj.put("time_start", timeStart);//交易起始時(shí)間
nativeObj.put("time_expire", timeExpire)//交易結(jié)束時(shí)間
nativeObj.put("notify_url",CustomizedPropertyPlaceholderConfigurer.getContextProperty("wxurl")+"/weixin_callback/weixinCallback/init.action");//通知地址
nativeObj.put("trade_type", "JSAPI");//交易類型
String sign = GetBizSign(nativeObj);
nativeObj.put("sign", sign.toUpperCase());
return CommonUtil.ArrayToXml(nativeObj);
}
/**
* 微信關(guān)閉訂單
* @param nonceStr
* @param orderDescribe
* @param orderNo
* @param price
* @param timeStart
* @param timeExpire
* @param openId
* @return
* @throws SDKRuntimeException
*/
public static String CreateCloseOrder(String outTradeNo,String nonceStr) throws SDKRuntimeException {
HashMap<String, String> nativeObj = new HashMap<String, String>();
nativeObj.put("appid", "見公眾賬號(hào)");//公眾賬號(hào)Id
nativeObj.put("mch_id", "見郵件");//商戶號(hào)
nativeObj.put("out_trade_no", outTradeNo);//商戶訂單號(hào)(全局唯一)
nativeObj.put("nonce_str", nonceStr);//隨機(jī)字符串
 String sign = GetBizSign(nativeObj);
nativeObj.put("sign", sign.toUpperCase());
 return CommonUtil.ArrayToXml(nativeObj);
}
}

4.調(diào)用微信支付接口 

package com.pay.controller.weixin;

import java.io.File;
import java.io.FileInputStream;
import java.security.KeyStore;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.net.ssl.SSLContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.pay.bo.PayHist;
import com.pay.constants.PayHistoryPayStatus;
import com.pay.constants.PayHistoryPayType;
import com.pay.service.WeiXinPayService;
import com.pay.utils.weixin.ClientCustomSSL;
import com.pay.utils.weixin.CloseWeiXinOrderUtils;
import com.pay.utils.weixin.CustomizedPropertyPlaceholderConfigurer;


@RestController
@RequestMapping("/Pay")
public class WeiXinPayController {
 
 
 @Autowired
 WeiXinPayService weiXinPayService;
 private static long standardTime = 1662652800000L;
 
 /**
 * 返回生成二維碼的url
 * @param request
 * @param response
 * @return
 */
 @RequestMapping(value="/getUrl",method=RequestMethod.POST)
 @ResponseStatus(HttpStatus.OK)
 public Object getUrl(HttpServletResponse response,@RequestBody String body){
 try{
  JSONObject jsonO = JSONObject.fromObject(body);
  PayHist ph = null;
//  List<Map<String,Object>> td = weiXinPayService.getTrade(orderNo);
  Date dt = new Date();
  SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
  String nonceStr = sdf.format(dt).toString();
  Date now = new Date();
  
  String tradePayNo = jsonO.get("orderNo").toString()+String.format("%10d",standardTime - now.getTime()).substring(0, 10);
  System.out.println("訂單標(biāo)號(hào)orderNo======="+jsonO.get("orderNo").toString());
  System.out.println("10位隨機(jī)數(shù)======="+String.format("%10d",standardTime - now.getTime()).substring(0, 10));
  String price = Math.round(Float.valueOf(jsonO.get("price").toString())*100)+"";
  Long timeExpireStrOld = dt.getTime();
  Long timeNew = Long.parseLong(CustomizedPropertyPlaceholderConfigurer.getContextProperty("weixin.send2finish.overtime").toString());
  Long timeExpireNew = timeExpireStrOld+timeNew;
  Date dtTimeExpire = new Date(timeExpireNew);
  SimpleDateFormat dtSdf = new SimpleDateFormat("yyyyMMddHHmmss");
  String timeExpire = dtSdf.format(dtTimeExpire).toString();
  System.out.println("nonceStr=="+nonceStr);
  System.out.println("orderNo=="+jsonO.get("orderNo").toString());
  System.out.println("price=="+price);
  System.out.println("timeStart=="+nonceStr);
  System.out.println("timeExpire=="+timeExpire);
  
  
  JSONObject result = (JSONObject) setUrl(nonceStr,"訂單",tradePayNo,price,nonceStr,timeExpire);
  
  if(result.get("status").toString().equals("success")){
  ph = new PayHist();
  ph.setTradePayUrl(result.getString("weixinPayUrl"));//此字段為支付鏈接,可以此鏈接生成二維碼掃碼支付
  ph.setPayTradeNo(jsonO.get("orderNo").toString());
  ph.setTradePayNo(tradePayNo);
  ph.setPayStatus(PayHistoryPayStatus.WECHAT_PAY_STATUS_WAIT);
  ph.setPayType(PayHistoryPayType.WECHAT);
  ph.setAppKey(jsonO.getString("appKey").toString());
  ph.setPayAmount(price);
  
  result.put("payTradeNo", ph.getPayTradeNo());
  result.put("tradePayNo", ph.getTradePayNo());
  result.put("payStatus", ph.getPayStatus());
  result.put("payType", ph.getPayType());
  
  }  
  return result;
  
  
 }catch(Exception e){
  e.printStackTrace();
  JSONObject result = new JSONObject();
  result.put("status","error");
  result.put("msg",e.getMessage());
//  return result.toString();
 }
 return null;
 
 
 }

 public Object setUrl(String nonceStr,String orderDescribe,String orderNo,String price,String timeStart,String timeExpire) {
 try{
  
  KeyStore keyStore = KeyStore.getInstance("PKCS12");
  FileInputStream instream = new FileInputStream(new File(微信證書絕對(duì)路徑));
  try {
  keyStore.load(instream, "商戶ID".toCharArray());
  }finally {
  instream.close();
  }

  // Trust own CA and all self-signed certs
  SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore,<span style="font-family: Arial, Helvetica, sans-serif;">商戶ID</span>.toCharArray()).build();
  // Allow TLSv1 protocol only
  SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
   sslcontext, new String[] { "TLSv1" }, null,
   SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
  CloseableHttpClient httpclient = HttpClients.custom()
   .setSSLSocketFactory(sslsf).build();
  // HttpGet httpget = new
  // HttpGet("https://api.mch.weixin.qq.com/secapi/pay/refund");
  HttpPost httppost = new HttpPost(
   "https://api.mch.weixin.qq.com/pay/unifiedorder");
  
  String xml = ClientCustomSSL.CreateNativePackage(nonceStr,orderDescribe,orderNo,price,timeStart,timeExpire);
  try {

  
  StringEntity se = new StringEntity(xml);
  
  httppost.setEntity(se);

  System.out.println("executing request" + httppost.getRequestLine());

  CloseableHttpResponse responseEntry = httpclient.execute(httppost);
  try {
   HttpEntity entity = responseEntry.getEntity();

   System.out.println("----------------------------------------");
   System.out.println(responseEntry.getStatusLine());
   if (entity != null) {
   System.out.println("Response content length: "
    + entity.getContentLength());
  /* BufferedReader bufferedReader = new BufferedReader(
    new InputStreamReader(entity.getContent()));
   String text;
   while ((text = bufferedReader.readLine()) != null) {
    System.out.println("======="+text);
   }*/ 
      
   SAXReader saxReader = new SAXReader();
   Document document = saxReader.read(entity.getContent());
   Element rootElt = document.getRootElement();
   System.out.println("根節(jié)點(diǎn):" + rootElt.getName());
   System.out.println("==="+rootElt.elementText("result_code"));
   System.out.println("==="+rootElt.elementText("return_msg"));
   String resultCode = rootElt.elementText("result_code");
   JSONObject result = new JSONObject();  
   
   Document documentXml =DocumentHelper.parseText(xml);
   Element rootEltXml = documentXml.getRootElement();
   
   if(resultCode.equals("SUCCESS")){
    System.out.println("=================prepay_id===================="+ rootElt.elementText("prepay_id"));
    System.out.println("=================sign===================="+ rootEltXml.elementText("sign"));
    result.put("weixinPayUrl", rootElt.elementText("code_url"));
    result.put("prepayId", rootElt.elementText("prepay_id"));
    result.put("status","success");
    result.put("msg","success");
   }else{
    result.put("status","false");
    result.put("msg",rootElt.elementText("err_code_des"));
   }
   
   
   return result;

   }
   EntityUtils.consume(entity);
  }
  finally {
   responseEntry.close();
  }
  }
  finally {
  httpclient.close();
  }
  return null;
  
  
 }catch(Exception e){
  e.printStackTrace();
  JSONObject result = new JSONObject();
  result.put("status","error");
  result.put("msg",e.getMessage());
  return result;
 }
 }
 
}


httpclient  jar包和json jar包:下載地址。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Java Idea高效率配置技巧實(shí)例解析

    Java Idea高效率配置技巧實(shí)例解析

    這篇文章主要介紹了Java Idea高效率配置技巧實(shí)例解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-04-04
  • SpringBoot 快速實(shí)現(xiàn) api 加密的方法

    SpringBoot 快速實(shí)現(xiàn) api 加密的方法

    在項(xiàng)目中,為了保證數(shù)據(jù)的安全,我們常常會(huì)對(duì)傳遞的數(shù)據(jù)進(jìn)行加密,常用的加密算法包括對(duì)稱加密(AES)和非對(duì)稱加密(RSA),本文給大家介紹SpringBoot 快速實(shí)現(xiàn) api 加密,感興趣的朋友一起看看吧
    2023-10-10
  • java不同版本在多線程中使用隨機(jī)數(shù)生成器的實(shí)現(xiàn)

    java不同版本在多線程中使用隨機(jī)數(shù)生成器的實(shí)現(xiàn)

    本文主要介紹了java不同版本在多線程中使用隨機(jī)數(shù)生成器的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-04-04
  • Java多線程中ThreadLocal解讀

    Java多線程中ThreadLocal解讀

    這篇文章主要介紹了Java多線程中ThreadLocal解讀,??多線程訪問(wèn)同一個(gè)共享變量的時(shí)候容易出現(xiàn)并發(fā)問(wèn)題,因此為了保證線程安全性,我們都會(huì)采用加鎖的方式,而ThreadLocal是除加鎖方式之外的另一種保證線程安全性的方法,需要的朋友可以參考下
    2023-09-09
  • MyBatis中resultType屬性的使用

    MyBatis中resultType屬性的使用

    這篇文章主要介紹了MyBatis中resultType屬性的使用,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-09-09
  • JAVA虛擬機(jī)中 -D, -X, -XX ,-server參數(shù)使用

    JAVA虛擬機(jī)中 -D, -X, -XX ,-server參數(shù)使用

    本文主要介紹了JAVA虛擬機(jī)中 -D, -X, -XX ,-server參數(shù)使用,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2025-03-03
  • 關(guān)于synchronized、volatile、ReentrantLock的區(qū)別與對(duì)比

    關(guān)于synchronized、volatile、ReentrantLock的區(qū)別與對(duì)比

    這篇文章主要介紹了關(guān)于synchronized、volatile、ReentrantLock的區(qū)別與對(duì)比,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-04-04
  • Java調(diào)用第三方接口示范的實(shí)現(xiàn)

    Java調(diào)用第三方接口示范的實(shí)現(xiàn)

    這篇文章主要介紹了Java調(diào)用第三方接口示范的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-09-09
  • SpringBoot使用AOP+注解實(shí)現(xiàn)簡(jiǎn)單的權(quán)限驗(yàn)證的方法

    SpringBoot使用AOP+注解實(shí)現(xiàn)簡(jiǎn)單的權(quán)限驗(yàn)證的方法

    這篇文章主要介紹了SpringBoot使用AOP+注解實(shí)現(xiàn)簡(jiǎn)單的權(quán)限驗(yàn)證的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-05-05
  • 并發(fā)編程ConcurrentLinkedQueue示例詳解

    并發(fā)編程ConcurrentLinkedQueue示例詳解

    這篇文章主要為大家介紹了并發(fā)編程ConcurrentLinkedQueue使用示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-12-12

最新評(píng)論

甘孜县| 关岭| 鹿邑县| 邳州市| 平利县| 邹平县| 罗山县| 碌曲县| 滨海县| 富源县| 子长县| 衡水市| 九龙县| 呈贡县| 轮台县| 岳西县| 巴中市| 泸水县| 都江堰市| 阿图什市| 鄂州市| 潼南县| 舞阳县| 高台县| 剑川县| 汕尾市| 枝江市| 汨罗市| 敦化市| 延吉市| 宜兰市| 疏附县| 鸡东县| 青铜峡市| 皋兰县| 宾阳县| 尤溪县| 浦县| 宁武县| 华坪县| 方正县|