Java實(shí)現(xiàn)操作JSON的便捷工具類(lèi)完整實(shí)例【重寫(xiě)Google的Gson】
本文實(shí)例講述了Java實(shí)現(xiàn)操作JSON的便捷工具類(lèi)。分享給大家供大家參考,具體如下:
對(duì)于JSON數(shù)據(jù)格式的處理,自開(kāi)發(fā)Java以來(lái),已用過(guò)多種JSON的開(kāi)源工具,用得最好,也用得最High的恐怕要屬Google的Gson了。
特別為它寫(xiě)了一個(gè)工具類(lèi),放入常備工具中,方便使用。下面是為GSON 1.5版本重寫(xiě)的工具類(lèi)。
依賴(lài)包:
slf4j-api-1.6.0.jar
slf4j-log4j12-1.6.0.jar
log4j-1.2.15.jar
gson-1.5.jar
/** * Copyright 2010 Fuchun. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package my.tools; import java.lang.reflect.Type; import java.util.Collection; import java.util.Enumeration; import java.util.Iterator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.reflect.TypeToken; import org.apache.commons.lang.StringUtils; /** * 包含操作 {@code JSON} 數(shù)據(jù)的常用方法的工具類(lèi)。 * <p /> * 該工具類(lèi)使用的 {@code JSON} 轉(zhuǎn)換引擎是 <a rel="external nofollow" rel="external nofollow" mce_ rel="external nofollow" rel="external nofollow" target="_blank"> * {@code Google Gson}</a>。 下面是工具類(lèi)的使用案例: * * <pre> * public class User { * @SerializedName("pwd") * private String password; * @Expose * @SerializedName("uname") * private String username; * @Expose * @Since(1.1) * private String gender; * @Expose * @Since(1.0) * private String sex; * * public User() {} * public User(String username, String password, String gender) { * // user constructor code... ... ... * } * * public String getUsername() * ... ... ... * } * List<User> userList = new LinkedList<User>(); * User jack = new User("Jack", "123456", "Male"); * User marry = new User("Marry", "888888", "Female"); * userList.add(jack); * userList.add(marry); * Type targetType = new TypeToken<List<User>>(){}.getType(); * String sUserList1 = JSONUtils.toJson(userList, targetType); * sUserList1 ----> [{"uname":"jack","gender":"Male","sex":"Male"},{"uname":"marry","gender":"Female","sex":"Female"}] * String sUserList2 = JSONUtils.toJson(userList, targetType, false); * sUserList2 ----> [{"uname":"jack","pwd":"123456","gender":"Male","sex":"Male"},{"uname":"marry","pwd":"888888","gender":"Female","sex":"Female"}] * String sUserList3 = JSONUtils.toJson(userList, targetType, 1.0d, true); * sUserList3 ----> [{"uname":"jack","sex":"Male"},{"uname":"marry","sex":"Female"}] * </pre> * * @author Fuchun * @since ay-commons-lang 1.0 * @version 1.1.0 */ public class JSONUtils { private static final Logger LOGGER = LoggerFactory.getLogger(JSONUtils.class); /** 空的 {@code JSON} 數(shù)據(jù) - <code>"{}"</code>。 */ public static final String EMPTY_JSON = "{}"; /** 空的 {@code JSON} 數(shù)組(集合)數(shù)據(jù) - {@code "[]"}。 */ public static final String EMPTY_JSON_ARRAY = "[]"; /** 默認(rèn)的 {@code JSON} 日期/時(shí)間字段的格式化模式。 */ public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss SSS"; /** {@code Google Gson} 的 <code>@Since</code> 注解常用的版本號(hào)常量 - {@code 1.0}。 */ public static final double SINCE_VERSION_10 = 1.0d; /** {@code Google Gson} 的 <code>@Since</code> 注解常用的版本號(hào)常量 - {@code 1.1}。 */ public static final double SINCE_VERSION_11 = 1.1d; /** {@code Google Gson} 的 <code>@Since</code> 注解常用的版本號(hào)常量 - {@code 1.2}。 */ public static final double SINCE_VERSION_12 = 1.2d; /** {@code Google Gson} 的 <code>@Until</code> 注解常用的版本號(hào)常量 - {@code 1.0}。 */ public static final double UNTIL_VERSION_10 = SINCE_VERSION_10; /** {@code Google Gson} 的 <code>@Until</code> 注解常用的版本號(hào)常量 - {@code 1.1}。 */ public static final double UNTIL_VERSION_11 = SINCE_VERSION_11; /** {@code Google Gson} 的 <code>@Until</code> 注解常用的版本號(hào)常量 - {@code 1.2}。 */ public static final double UNTIL_VERSION_12 = SINCE_VERSION_12; /** * <p> * <code>JSONUtils</code> instances should NOT be constructed in standard programming. Instead, * the class should be used as <code>JSONUtils.fromJson("foo");</code>. * </p> * <p> * This constructor is public to permit tools that require a JavaBean instance to operate. * </p> */ public JSONUtils() { super(); } /** * 將給定的目標(biāo)對(duì)象根據(jù)指定的條件參數(shù)轉(zhuǎn)換成 {@code JSON} 格式的字符串。 * <p /> * <strong>該方法轉(zhuǎn)換發(fā)生錯(cuò)誤時(shí),不會(huì)拋出任何異常。若發(fā)生錯(cuò)誤時(shí),曾通對(duì)象返回 <code>"{}"</code>; 集合或數(shù)組對(duì)象返回 <code>"[]"</code> * </strong> * * @param target 目標(biāo)對(duì)象。 * @param targetType 目標(biāo)對(duì)象的類(lèi)型。 * @param isSerializeNulls 是否序列化 {@code null} 值字段。 * @param version 字段的版本號(hào)注解。 * @param datePattern 日期字段的格式化模式。 * @param excludesFieldsWithoutExpose 是否排除未標(biāo)注 {@literal @Expose} 注解的字段。 * @return 目標(biāo)對(duì)象的 {@code JSON} 格式的字符串。 * @since 1.0 */ public static String toJson(Object target, Type targetType, boolean isSerializeNulls, Double version, String datePattern, boolean excludesFieldsWithoutExpose) { if (target == null) return EMPTY_JSON; GsonBuilder builder = new GsonBuilder(); if (isSerializeNulls) builder.serializeNulls(); if (version != null) builder.setVersion(version.doubleValue()); if (StringUtils.isBlank(datePattern)) datePattern = DEFAULT_DATE_PATTERN; builder.setDateFormat(datePattern); if (excludesFieldsWithoutExpose) builder.excludeFieldsWithoutExposeAnnotation(); return toJson(target, targetType, builder); } /** * 將給定的目標(biāo)對(duì)象轉(zhuǎn)換成 {@code JSON} 格式的字符串。<strong>此方法只用來(lái)轉(zhuǎn)換普通的 {@code JavaBean} 對(duì)象。</strong> * <ul> * <li>該方法只會(huì)轉(zhuǎn)換標(biāo)有 {@literal @Expose} 注解的字段;</li> * <li>該方法不會(huì)轉(zhuǎn)換 {@code null} 值字段;</li> * <li>該方法會(huì)轉(zhuǎn)換所有未標(biāo)注或已標(biāo)注 {@literal @Since} 的字段;</li> * <li>該方法轉(zhuǎn)換時(shí)使用默認(rèn)的 日期/時(shí)間 格式化模式 - {@code yyyy-MM-dd HH:mm:ss SSS};</li> * </ul> * * @param target 要轉(zhuǎn)換成 {@code JSON} 的目標(biāo)對(duì)象。 * @return 目標(biāo)對(duì)象的 {@code JSON} 格式的字符串。 * @since 1.0 */ public static String toJson(Object target) { return toJson(target, null, false, null, null, true); } /** * 將給定的目標(biāo)對(duì)象轉(zhuǎn)換成 {@code JSON} 格式的字符串。<strong>此方法只用來(lái)轉(zhuǎn)換普通的 {@code JavaBean} 對(duì)象。</strong> * <ul> * <li>該方法只會(huì)轉(zhuǎn)換標(biāo)有 {@literal @Expose} 注解的字段;</li> * <li>該方法不會(huì)轉(zhuǎn)換 {@code null} 值字段;</li> * <li>該方法會(huì)轉(zhuǎn)換所有未標(biāo)注或已標(biāo)注 {@literal @Since} 的字段;</li> * </ul> * * @param target 要轉(zhuǎn)換成 {@code JSON} 的目標(biāo)對(duì)象。 * @param datePattern 日期字段的格式化模式。 * @return 目標(biāo)對(duì)象的 {@code JSON} 格式的字符串。 * @since 1.0 */ public static String toJson(Object target, String datePattern) { return toJson(target, null, false, null, datePattern, true); } /** * 將給定的目標(biāo)對(duì)象轉(zhuǎn)換成 {@code JSON} 格式的字符串。<strong>此方法只用來(lái)轉(zhuǎn)換普通的 {@code JavaBean} 對(duì)象。</strong> * <ul> * <li>該方法只會(huì)轉(zhuǎn)換標(biāo)有 {@literal @Expose} 注解的字段;</li> * <li>該方法不會(huì)轉(zhuǎn)換 {@code null} 值字段;</li> * <li>該方法轉(zhuǎn)換時(shí)使用默認(rèn)的 日期/時(shí)間 格式化模式 - {@code yyyy-MM-dd HH:mm:ss SSS};</li> * </ul> * * @param target 要轉(zhuǎn)換成 {@code JSON} 的目標(biāo)對(duì)象。 * @param version 字段的版本號(hào)注解({@literal @Since})。 * @return 目標(biāo)對(duì)象的 {@code JSON} 格式的字符串。 * @since 1.0 */ public static String toJson(Object target, Double version) { return toJson(target, null, false, version, null, true); } /** * 將給定的目標(biāo)對(duì)象轉(zhuǎn)換成 {@code JSON} 格式的字符串。<strong>此方法只用來(lái)轉(zhuǎn)換普通的 {@code JavaBean} 對(duì)象。</strong> * <ul> * <li>該方法不會(huì)轉(zhuǎn)換 {@code null} 值字段;</li> * <li>該方法會(huì)轉(zhuǎn)換所有未標(biāo)注或已標(biāo)注 {@literal @Since} 的字段;</li> * <li>該方法轉(zhuǎn)換時(shí)使用默認(rèn)的 日期/時(shí)間 格式化模式 - {@code yyyy-MM-dd HH:mm:ss SSS};</li> * </ul> * * @param target 要轉(zhuǎn)換成 {@code JSON} 的目標(biāo)對(duì)象。 * @param excludesFieldsWithoutExpose 是否排除未標(biāo)注 {@literal @Expose} 注解的字段。 * @return 目標(biāo)對(duì)象的 {@code JSON} 格式的字符串。 * @since 1.0 */ public static String toJson(Object target, boolean excludesFieldsWithoutExpose) { return toJson(target, null, false, null, null, excludesFieldsWithoutExpose); } /** * 將給定的目標(biāo)對(duì)象轉(zhuǎn)換成 {@code JSON} 格式的字符串。<strong>此方法只用來(lái)轉(zhuǎn)換普通的 {@code JavaBean} 對(duì)象。</strong> * <ul> * <li>該方法不會(huì)轉(zhuǎn)換 {@code null} 值字段;</li> * <li>該方法轉(zhuǎn)換時(shí)使用默認(rèn)的 日期/時(shí)間 格式化模式 - {@code yyyy-MM-dd HH:mm:ss SSS};</li> * </ul> * * @param target 要轉(zhuǎn)換成 {@code JSON} 的目標(biāo)對(duì)象。 * @param version 字段的版本號(hào)注解({@literal @Since})。 * @param excludesFieldsWithoutExpose 是否排除未標(biāo)注 {@literal @Expose} 注解的字段。 * @return 目標(biāo)對(duì)象的 {@code JSON} 格式的字符串。 * @since 1.0 */ public static String toJson(Object target, Double version, boolean excludesFieldsWithoutExpose) { return toJson(target, null, false, version, null, excludesFieldsWithoutExpose); } /** * 將給定的目標(biāo)對(duì)象轉(zhuǎn)換成 {@code JSON} 格式的字符串。<strong>此方法通常用來(lái)轉(zhuǎn)換使用泛型的對(duì)象。</strong> * <ul> * <li>該方法只會(huì)轉(zhuǎn)換標(biāo)有 {@literal @Expose} 注解的字段;</li> * <li>該方法不會(huì)轉(zhuǎn)換 {@code null} 值字段;</li> * <li>該方法會(huì)轉(zhuǎn)換所有未標(biāo)注或已標(biāo)注 {@literal @Since} 的字段;</li> * <li>該方法轉(zhuǎn)換時(shí)使用默認(rèn)的 日期/時(shí)間 格式化模式 - {@code yyyy-MM-dd HH:mm:ss SSSS};</li> * </ul> * * @param target 要轉(zhuǎn)換成 {@code JSON} 的目標(biāo)對(duì)象。 * @param targetType 目標(biāo)對(duì)象的類(lèi)型。 * @return 目標(biāo)對(duì)象的 {@code JSON} 格式的字符串。 * @since 1.0 */ public static String toJson(Object target, Type targetType) { return toJson(target, targetType, false, null, null, true); } /** * 將給定的目標(biāo)對(duì)象轉(zhuǎn)換成 {@code JSON} 格式的字符串。<strong>此方法通常用來(lái)轉(zhuǎn)換使用泛型的對(duì)象。</strong> * <ul> * <li>該方法只會(huì)轉(zhuǎn)換標(biāo)有 {@literal @Expose} 注解的字段;</li> * <li>該方法不會(huì)轉(zhuǎn)換 {@code null} 值字段;</li> * <li>該方法轉(zhuǎn)換時(shí)使用默認(rèn)的 日期/時(shí)間 格式化模式 - {@code yyyy-MM-dd HH:mm:ss SSSS};</li> * </ul> * * @param target 要轉(zhuǎn)換成 {@code JSON} 的目標(biāo)對(duì)象。 * @param targetType 目標(biāo)對(duì)象的類(lèi)型。 * @param version 字段的版本號(hào)注解({@literal @Since})。 * @return 目標(biāo)對(duì)象的 {@code JSON} 格式的字符串。 * @since 1.0 */ public static String toJson(Object target, Type targetType, Double version) { return toJson(target, targetType, false, version, null, true); } /** * 將給定的目標(biāo)對(duì)象轉(zhuǎn)換成 {@code JSON} 格式的字符串。<strong>此方法通常用來(lái)轉(zhuǎn)換使用泛型的對(duì)象。</strong> * <ul> * <li>該方法不會(huì)轉(zhuǎn)換 {@code null} 值字段;</li> * <li>該方法會(huì)轉(zhuǎn)換所有未標(biāo)注或已標(biāo)注 {@literal @Since} 的字段;</li> * <li>該方法轉(zhuǎn)換時(shí)使用默認(rèn)的 日期/時(shí)間 格式化模式 - {@code yyyy-MM-dd HH:mm:ss SSS};</li> * </ul> * * @param target 要轉(zhuǎn)換成 {@code JSON} 的目標(biāo)對(duì)象。 * @param targetType 目標(biāo)對(duì)象的類(lèi)型。 * @param excludesFieldsWithoutExpose 是否排除未標(biāo)注 {@literal @Expose} 注解的字段。 * @return 目標(biāo)對(duì)象的 {@code JSON} 格式的字符串。 * @since 1.0 */ public static String toJson(Object target, Type targetType, boolean excludesFieldsWithoutExpose) { return toJson(target, targetType, false, null, null, excludesFieldsWithoutExpose); } /** * 將給定的目標(biāo)對(duì)象轉(zhuǎn)換成 {@code JSON} 格式的字符串。<strong>此方法通常用來(lái)轉(zhuǎn)換使用泛型的對(duì)象。</strong> * <ul> * <li>該方法不會(huì)轉(zhuǎn)換 {@code null} 值字段;</li> * <li>該方法轉(zhuǎn)換時(shí)使用默認(rèn)的 日期/時(shí)間 格式化模式 - {@code yyyy-MM-dd HH:mm:ss SSS};</li> * </ul> * * @param target 要轉(zhuǎn)換成 {@code JSON} 的目標(biāo)對(duì)象。 * @param targetType 目標(biāo)對(duì)象的類(lèi)型。 * @param version 字段的版本號(hào)注解({@literal @Since})。 * @param excludesFieldsWithoutExpose 是否排除未標(biāo)注 {@literal @Expose} 注解的字段。 * @return 目標(biāo)對(duì)象的 {@code JSON} 格式的字符串。 * @since 1.0 */ public static String toJson(Object target, Type targetType, Double version, boolean excludesFieldsWithoutExpose) { return toJson(target, targetType, false, version, null, excludesFieldsWithoutExpose); } /** * 將給定的 {@code JSON} 字符串轉(zhuǎn)換成指定的類(lèi)型對(duì)象。 * * @param <T> 要轉(zhuǎn)換的目標(biāo)類(lèi)型。 * @param json 給定的 {@code JSON} 字符串。 * @param token {@code com.google.gson.reflect.TypeToken} 的類(lèi)型指示類(lèi)對(duì)象。 * @param datePattern 日期格式模式。 * @return 給定的 {@code JSON} 字符串表示的指定的類(lèi)型對(duì)象。 * @since 1.0 */ public static <T> T fromJson(String json, TypeToken<T> token, String datePattern) { if (StringUtils.isBlank(json)) { return null; } GsonBuilder builder = new GsonBuilder(); if (StringUtils.isBlank(datePattern)) { datePattern = DEFAULT_DATE_PATTERN; } Gson gson = builder.create(); try { return gson.fromJson(json, token.getType()); } catch (Exception ex) { LOGGER.error(json + " 無(wú)法轉(zhuǎn)換為 " + token.getRawType().getName() + " 對(duì)象!", ex); return null; } } /** * 將給定的 {@code JSON} 字符串轉(zhuǎn)換成指定的類(lèi)型對(duì)象。 * * @param <T> 要轉(zhuǎn)換的目標(biāo)類(lèi)型。 * @param json 給定的 {@code JSON} 字符串。 * @param token {@code com.google.gson.reflect.TypeToken} 的類(lèi)型指示類(lèi)對(duì)象。 * @return 給定的 {@code JSON} 字符串表示的指定的類(lèi)型對(duì)象。 * @since 1.0 */ public static <T> T fromJson(String json, TypeToken<T> token) { return fromJson(json, token, null); } /** * 將給定的 {@code JSON} 字符串轉(zhuǎn)換成指定的類(lèi)型對(duì)象。<strong>此方法通常用來(lái)轉(zhuǎn)換普通的 {@code JavaBean} 對(duì)象。</strong> * * @param <T> 要轉(zhuǎn)換的目標(biāo)類(lèi)型。 * @param json 給定的 {@code JSON} 字符串。 * @param clazz 要轉(zhuǎn)換的目標(biāo)類(lèi)。 * @param datePattern 日期格式模式。 * @return 給定的 {@code JSON} 字符串表示的指定的類(lèi)型對(duì)象。 * @since 1.0 */ public static <T> T fromJson(String json, Class<T> clazz, String datePattern) { if (StringUtils.isBlank(json)) { return null; } GsonBuilder builder = new GsonBuilder(); if (StringUtils.isBlank(datePattern)) { datePattern = DEFAULT_DATE_PATTERN; } Gson gson = builder.create(); try { return gson.fromJson(json, clazz); } catch (Exception ex) { LOGGER.error(json + " 無(wú)法轉(zhuǎn)換為 " + clazz.getName() + " 對(duì)象!", ex); return null; } } /** * 將給定的 {@code JSON} 字符串轉(zhuǎn)換成指定的類(lèi)型對(duì)象。<strong>此方法通常用來(lái)轉(zhuǎn)換普通的 {@code JavaBean} 對(duì)象。</strong> * * @param <T> 要轉(zhuǎn)換的目標(biāo)類(lèi)型。 * @param json 給定的 {@code JSON} 字符串。 * @param clazz 要轉(zhuǎn)換的目標(biāo)類(lèi)。 * @return 給定的 {@code JSON} 字符串表示的指定的類(lèi)型對(duì)象。 * @since 1.0 */ public static <T> T fromJson(String json, Class<T> clazz) { return fromJson(json, clazz, null); } /** * 將給定的目標(biāo)對(duì)象根據(jù){@code GsonBuilder} 所指定的條件參數(shù)轉(zhuǎn)換成 {@code JSON} 格式的字符串。 * <p /> * 該方法轉(zhuǎn)換發(fā)生錯(cuò)誤時(shí),不會(huì)拋出任何異常。若發(fā)生錯(cuò)誤時(shí),{@code JavaBean} 對(duì)象返回 <code>"{}"</code>; 集合或數(shù)組對(duì)象返回 * <code>"[]"</code>。 其本基本類(lèi)型,返回相應(yīng)的基本值。 * * @param target 目標(biāo)對(duì)象。 * @param targetType 目標(biāo)對(duì)象的類(lèi)型。 * @param builder 可定制的{@code Gson} 構(gòu)建器。 * @return 目標(biāo)對(duì)象的 {@code JSON} 格式的字符串。 * @since 1.1 */ public static String toJson(Object target, Type targetType, GsonBuilder builder) { if (target == null) return EMPTY_JSON; Gson gson = null; if (builder == null) { gson = new Gson(); } else { gson = builder.create(); } String result = EMPTY_JSON; try { if (targetType == null) { result = gson.toJson(target); } else { result = gson.toJson(target, targetType); } } catch (Exception ex) { LOGGER.warn("目標(biāo)對(duì)象 " + target.getClass().getName() + " 轉(zhuǎn)換 JSON 字符串時(shí),發(fā)生異常!", ex); if (target instanceof Collection<?> || target instanceof Iterator<?> || target instanceof Enumeration<?> || target.getClass().isArray()) { result = EMPTY_JSON_ARRAY; } } return result; } }
PS:關(guān)于json操作,這里再為大家推薦幾款比較實(shí)用的json在線(xiàn)工具供大家參考使用:
在線(xiàn)JSON代碼檢驗(yàn)、檢驗(yàn)、美化、格式化工具:
http://tools.jb51.net/code/json
JSON在線(xiàn)格式化工具:
http://tools.jb51.net/code/jsonformat
在線(xiàn)XML/JSON互相轉(zhuǎn)換工具:
http://tools.jb51.net/code/xmljson
json代碼在線(xiàn)格式化/美化/壓縮/編輯/轉(zhuǎn)換工具:
http://tools.jb51.net/code/jsoncodeformat
在線(xiàn)json壓縮/轉(zhuǎn)義工具:
http://tools.jb51.net/code/json_yasuo_trans
更多關(guān)于java相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《Java操作json格式數(shù)據(jù)技巧總結(jié)》、《Java數(shù)組操作技巧總結(jié)》、《Java字符與字符串操作技巧總結(jié)》、《Java數(shù)學(xué)運(yùn)算技巧總結(jié)》、《Java數(shù)據(jù)結(jié)構(gòu)與算法教程》及《Java操作DOM節(jié)點(diǎn)技巧總結(jié)》
希望本文所述對(duì)大家java程序設(shè)計(jì)有所幫助。
相關(guān)文章
Java多線(xiàn)程之條件對(duì)象Condition
這篇文章主要介紹了Java多線(xiàn)程之條件對(duì)象Condition,Condition中的await()方法相當(dāng)于Object的wait()方法,Condition中的signal()方法相當(dāng)于Object的notify()方法,Condition中的signalAll()相當(dāng)于Object的notifyAll()方法,接下來(lái)和小編一起進(jìn)入文章了解更具體的內(nèi)容2021-10-10使用apache 的FileUtils處理文件的復(fù)制等操作方式
這篇文章主要介紹了使用apache 的FileUtils處理文件的復(fù)制等操作方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-07-07使用Mybatis對(duì)數(shù)據(jù)庫(kù)進(jìn)行單表操作的實(shí)現(xiàn)示例
這篇文章主要介紹了使用Mybatis對(duì)數(shù)據(jù)庫(kù)進(jìn)行單表操作的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08Springboot視頻接口報(bào)大量的ClientAbortException找不到原因的解決
本文主要介紹了Springboot視頻接口報(bào)大量的ClientAbortException找不到原因的解決,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-08-08簡(jiǎn)單了解SpringCloud運(yùn)行原理
這篇文章主要介紹了簡(jiǎn)單了解SpringCloud運(yùn)行原理,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-11-11Java線(xiàn)程并發(fā)工具類(lèi)CountDownLatch原理及用法
這篇文章主要介紹了Java線(xiàn)程并發(fā)工具類(lèi)CountDownLatch原理及用法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-10-10Java(基于Struts2) 分頁(yè)實(shí)現(xiàn)代碼
這篇文章介紹了Java(基于Struts2) 分頁(yè)實(shí)現(xiàn)代碼,有需要的朋友可以參考一下2013-10-10Java從單體架構(gòu)升級(jí)到微服務(wù)要注意的一些問(wèn)題
這篇文章主要介紹了Java從單體架構(gòu)升級(jí)到微服務(wù)要注意的一些問(wèn)題,對(duì)架構(gòu)感興趣的同學(xué),可以參考下2021-04-04SpringBoot項(xiàng)目中獲取IP地址的實(shí)現(xiàn)示例
OkHttp是一個(gè)由Square開(kāi)發(fā)的高效、現(xiàn)代的HTTP客戶(hù)端庫(kù),本文主要介紹了SpringBoot項(xiàng)目中獲取IP地址的實(shí)現(xiàn)示例,具有一定的參考價(jià)值,感興趣的可以了解一下2024-08-08