fix: 插件卸载

This commit is contained in:
taojinlong 2022-05-08 13:57:58 +08:00
parent 586f4b0307
commit 1925498e99
2 changed files with 3 additions and 6 deletions

View File

@ -26,8 +26,7 @@ public class LoadjarUtil {
public List<?> loadJar(String jarPath, MyPlugin myPlugin) throws Exception{
File jar = new File(jarPath);
URI uri = jar.toURI();
String moduleName = jarPath.substring(jarPath.lastIndexOf("/")+1,jarPath.lastIndexOf("."));
String moduleName = myPlugin.getModuleName() + "-" + myPlugin.getVersion();
if(ClassloaderResponsity.getInstance().containsClassLoader(moduleName)){
ClassloaderResponsity.getInstance().removeClassLoader(moduleName);

View File

@ -139,7 +139,7 @@ public class PluginService {
CacheUtils.removeAll(AuthConstants.USER_PERMISSION_CACHE_NAME);
} catch (Exception e) {
if (StringUtils.isNotEmpty(targetDir)) {
DeFileUtils.deleteFile(targetDir);
deleteJarFile(myPlugin);
}
LogUtil.error(e.getMessage(), e);
DEException.throwException(e);
@ -199,9 +199,7 @@ public class PluginService {
if(CollectionUtils.isNotEmpty(datasourceService.selectByType(myPlugin.getDsType()))){
throw new RuntimeException(Translator.get("i18n_plugin_not_allow_delete"));
}
SpringContextUtil.getBeanFactory().removeBeanDefinition(myPlugin.getDsType() + "DsProvider");
SpringContextUtil.getBeanFactory().removeBeanDefinition(myPlugin.getDsType() + "QueryProvider");
SpringContextUtil.getBeanFactory().removeBeanDefinition(myPlugin.getDsType() + "Service");
loadjarUtil.deleteModule(myPlugin.getModuleName() + "-" + myPlugin.getVersion());
}
myPluginMapper.deleteByPrimaryKey(pluginId);
return true;