fix(接口测试): 修复Mock后置脚本无法加载到minio上面jar包的问题

修复Mock后置脚本无法加载到minio上面jar包的问题
This commit is contained in:
song-tianyang 2023-02-17 19:15:41 +08:00 committed by 建国
parent 4493fe2923
commit b8a08589c5
1 changed files with 4 additions and 3 deletions

View File

@ -8,8 +8,7 @@ import io.metersphere.commons.utils.CommonBeanFactory;
import io.metersphere.commons.utils.JSON; import io.metersphere.commons.utils.JSON;
import io.metersphere.commons.utils.JSONUtil; import io.metersphere.commons.utils.JSONUtil;
import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.LogUtil;
import io.metersphere.jmeter.MsClassLoader; import io.metersphere.jmeter.ProjectClassLoader;
import io.metersphere.jmeter.MsDynamicClassLoader;
import io.metersphere.metadata.service.FileMetadataService; import io.metersphere.metadata.service.FileMetadataService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject; import org.json.JSONObject;
@ -78,7 +77,9 @@ public class MockScriptEngineUtils {
} }
if (engine != null) { if (engine != null) {
MsDynamicClassLoader loader = MsClassLoader.loadJar(getJarPaths(projectId)); ClassLoader loader = ProjectClassLoader.getClassLoader(new ArrayList<>() {{
this.add(projectId);
}});
Thread.currentThread().setContextClassLoader(loader); Thread.currentThread().setContextClassLoader(loader);
engine.eval(preScript); engine.eval(preScript);
} }