ShangHaiMesParent/moduleService/plcConnectModule/src/main/java/com/mes/common/ReadFile.java
@@ -2,21 +2,24 @@
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.*;
public class ReadFile {
    // 读取Json文件内容
    public static JSONObject readJson(String fileName) throws IOException {
    public static JSONObject readJson(String fileUrl) throws IOException {
        // 资源路径(相对于resources根目录)
        String resourcePath = "jsonFile/"+fileName;
        //String resourcePath = "jsonFile/"+fileName;
        //String resourcePath =  System.getProperty("user.dir") + "/JsonFile/"+fileName;
        String resourcePath =  fileUrl;
        // 获取类加载器
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        //ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        // 读取资源
        try (InputStream inputStream = classLoader.getResourceAsStream(resourcePath)) {
        try (InputStream inputStream = new FileInputStream(resourcePath)) {
        //try (InputStream inputStream = classLoader.getResourceAsStream(resourcePath)) {
            if (inputStream == null) {
                throw new IOException("资源未找到: " + resourcePath);
            }