1、检查idea是否有安装Java Bytecode Decomplier插件(基本上都有)
2、找到插件的运行包
目录:..idea\plugins\java-decompiler\lib\java-decompiler.jar
3、执行命令可生成原码jar包
java -cp “D:\decompiler\java-decompiler.jar” org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -dgs=true D:\decompiler\xxx\xxx-web-1.5.0-SNAPSHOT.jar src

4、工具方法

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil;

import java.io.*;
import java.util.List;

public class Decompiler {
    public static void main(String[] args) throws IOException, InterruptedException {
        String rootPath = "D:\\acloud_jar\\acloud_lib";
        List fileNames = FileUtil.listFileNames(rootPath);
        if (CollectionUtil.isEmpty(fileNames)) {
            return;
        }

        for (String fileName : fileNames) {
            if(!fileName.contains("acloud")){
                return;
            }
            Process p = Runtime.getRuntime().exec(String.format("java -cp \"D:\\acloud_jar\\java-decompiler.jar\" org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -dgs=true %s D:\\acloud_jar\\src", String.format("%s%s%s", rootPath, File.separator, fileName)));
            InputStream is = p.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
            p.waitFor();
            is.close();
            reader.close();
            p.destroy();
        }
    }
}