11111
parent
9a492da4a3
commit
ba0e92c608
|
@ -116,21 +116,31 @@ public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionM
|
||||||
|
|
||||||
// String filePath ="home/"+ossFilePath;
|
// String filePath ="home/"+ossFilePath;
|
||||||
String filePath = engineConfig.getSourcePath() + ossFilePath;
|
String filePath = engineConfig.getSourcePath() + ossFilePath;
|
||||||
//创建服务器项目容器的文件目录路径
|
//创建服务器项目容器的java源码文件目录路径
|
||||||
File serverFile = new File(engineWorkSourcePath, ossFilePath);
|
File serverFile = new File(engineWorkSourcePath, ossFilePath);
|
||||||
//如果目录不存在,则创建目录
|
//如果目录不存在,则创建目录
|
||||||
if (!serverFile.getParentFile().exists()) {
|
if (!serverFile.getParentFile().exists()) {
|
||||||
serverFile.getParentFile().mkdirs();
|
serverFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
|
serverFile.mkdirs();
|
||||||
|
|
||||||
|
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
|
||||||
|
|
||||||
|
writer.write(versionClazz);
|
||||||
|
System.out.println("文件已成功创建并写入Java源码。");
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("发生错误:" + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
File classFile = new File(engineWorkClassPath, ossFilePath2);
|
File classFile = new File(engineWorkClassPath, ossFilePath2);
|
||||||
//如果目录不存在,则创建目录
|
//如果目录不存在,则创建目录
|
||||||
if (!classFile.getParentFile().exists()) {
|
if (!classFile.getParentFile().exists()) {
|
||||||
classFile.getParentFile().mkdirs();
|
classFile.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
//下载文件到指定服务器目录下
|
|
||||||
OssUtil.downloadFileForBucket(bucketName, ossFilePath, filePath);
|
|
||||||
//编译
|
|
||||||
|
|
||||||
|
////下载文件到指定服务器目录下
|
||||||
|
// OssUtil.downloadFileForBucket(bucketName, ossFilePath, filePath);
|
||||||
|
//编译
|
||||||
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
|
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
|
||||||
//
|
//
|
||||||
InputStream first = null; // 程序的输入 null 用 system.in
|
InputStream first = null; // 程序的输入 null 用 system.in
|
||||||
|
@ -142,15 +152,12 @@ public class RuleEngineVersionServiceImpl extends ServiceImpl<RuleEngineVersionM
|
||||||
// 0 表示成功, 其他表示出现了错误
|
// 0 表示成功, 其他表示出现了错误
|
||||||
System.out.println(Arrays.toString(strings));
|
System.out.println(Arrays.toString(strings));
|
||||||
int i = javaCompiler.run(first, second, third, strings);
|
int i = javaCompiler.run(first, second, third, strings);
|
||||||
|
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
System.out.println("成功");
|
System.out.println("成功");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("错误");
|
System.out.println("错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
OssUtil.ssss(className);
|
OssUtil.ssss(className);
|
||||||
|
|
||||||
// 假设这是你的外部类文件路径
|
// 假设这是你的外部类文件路径
|
||||||
String externalClassFilePath =
|
String externalClassFilePath =
|
||||||
"home/lib/" + "com/muyu/rule/common/engine/value/" + className + Suffix_CLASS;
|
"home/lib/" + "com/muyu/rule/common/engine/value/" + className + Suffix_CLASS;
|
||||||
|
|
Loading…
Reference in New Issue