From 5693f178c662baa4e31ef19eea9214d20de7f176 Mon Sep 17 00:00:00 2001 From: linlihuiyang Date: Thu, 17 Oct 2019 16:21:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3Gson=E6=89=BE=E4=B8=8D?= =?UTF-8?q?=E5=88=B0=E5=8C=85=E7=9A=84bug=20(#141)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 解决Gson找不到包的bug * 解决Gson找不到包的bug --- .../me/zhengjie/service/impl/QiNiuServiceImpl.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/impl/QiNiuServiceImpl.java b/eladmin-tools/src/main/java/me/zhengjie/service/impl/QiNiuServiceImpl.java index 36888cb1..530a363d 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/impl/QiNiuServiceImpl.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/impl/QiNiuServiceImpl.java @@ -1,6 +1,6 @@ package me.zhengjie.service.impl; -import com.google.gson.Gson; +import com.alibaba.fastjson.JSON; import com.qiniu.common.QiniuException; import com.qiniu.http.Response; import com.qiniu.storage.BucketManager; @@ -16,7 +16,11 @@ import me.zhengjie.repository.QiNiuConfigRepository; import me.zhengjie.repository.QiniuContentRepository; import me.zhengjie.service.QiNiuService; import me.zhengjie.service.dto.QiniuQueryCriteria; -import me.zhengjie.utils.*; +import me.zhengjie.utils.FileUtil; +import me.zhengjie.utils.PageUtil; +import me.zhengjie.utils.QiNiuUtil; +import me.zhengjie.utils.QueryHelp; +import me.zhengjie.utils.ValidationUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Pageable; @@ -24,6 +28,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; + import java.util.Optional; /** @@ -91,7 +96,8 @@ public class QiNiuServiceImpl implements QiNiuService { } Response response = uploadManager.put(file.getBytes(), key, upToken); //解析上传成功的结果 - DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class); + + DefaultPutRet putRet = JSON.parseObject(response.bodyString(), DefaultPutRet.class); //存入数据库 QiniuContent qiniuContent = new QiniuContent(); qiniuContent.setSuffix(FileUtil.getExtensionName(putRet.key));