13693261870
2025-07-02 6708810c4de34dfb9513061432d656f91d56ee3a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.ruoyi.buss.common.liquor;
 
 
import com.ruoyi.framework.web.domain.server.Sys;
 
import java.util.ArrayList;
 
public class DemoApp {
 
    public static void main(String[] args) throws Exception{
        //可以复用(不要,不断的新建)
        String testParam = "hhhhh";
        String className = "HelloWorld";
        String classCode = "import java.util.List;\n\n"+
                "public class HelloWorld { " +
                "   public static String test99(List<String> code) { " +
                "       return \"hhhhhh\";" +
                "   } " +
                "}";
 
        Object obj = DynamicApp.exeJavaCode(classCode, className, "test99", new ArrayList<>());
 
        System.out.println(obj.toString());
//        //添加源码(可多个)并 构建
//        compiler.addSource(className, classCode).build();
//
//        Class<?> clazz = compiler.getClassLoader().loadClass(className);
//        clazz.getMethod("test99", String.class).invoke(null, testParam);
    }
 
 
}