绝对路径改为相对路径读取文件信息

develop
PL 4 months ago
parent 5658dabd32
commit dc2a311ead

@ -25,6 +25,7 @@ import cn.teammodel.utils.RepositoryUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.TypeReference;
import com.azure.cosmos.models.CosmosPatchOperations;
import com.sun.xml.internal.ws.transport.http.ResourceLoader;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
@ -33,6 +34,7 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import javax.annotation.Resource;
import java.io.*;
import java.net.URL;
import java.time.Instant;
import java.util.*;
@ -296,7 +298,9 @@ public class ChatMessageServiceImpl implements ChatMessageService {
StringBuilder builder = new StringBuilder();
String strData = JSON.toJSONString(chatCommentsDto.getData());
File file = new File("src/main/resources/Json/ChatModel.json");
File file = new File(ClassLoader.getSystemResource("Json/ChatModel.json").getPath()); //相对路径获取文件信息
//File file = new File("src/main/resources/Json/ChatModel.json"); //绝对路径获取文件信息
List<ChatModelDto> chatModels = new ArrayList<>();
ChatModelDto chatModel = null;
//chatModel = readerMethod(file);

Loading…
Cancel
Save