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);
|
}
|
|
|
}
|