diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java index 5dc0bf808..d8d34d5ad 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/spi/local/LocalPathContentParser.java @@ -5,6 +5,7 @@ import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.resource.ClassPathResource; import cn.hutool.core.io.resource.FileResource; import cn.hutool.core.io.resource.ResourceUtil; +import cn.hutool.core.util.ClassLoaderUtil; import cn.hutool.core.util.StrUtil; import com.yomahub.liteflow.exception.ConfigErrorException; import com.yomahub.liteflow.spi.PathContentParser; @@ -52,13 +53,17 @@ public class LocalPathContentParser implements PathContentParser { List result = new ArrayList<>(); for (String path : pathList) { - if (FileUtil.isAbsolutePath(path) && FileUtil.isFile(path)) { + if (FileUtil.isAbsolutePath(path) && FileUtil.isFile(path)) { path = FILE_URL_PREFIX + path; result.add(new FileResource(path).getFile().getAbsolutePath()); } else { if (!path.startsWith(CLASSPATH_URL_PREFIX)) { path = CLASSPATH_URL_PREFIX + path; - result.add(new ClassPathResource(path).getAbsolutePath()); + + // 这里会有自定义解析器 + if(ClassLoaderUtil.isPresent(path)){ + result.add(new ClassPathResource(path).getAbsolutePath()); + } } } } diff --git a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonPathContentParser.java b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonPathContentParser.java index fa14632a3..e25dbe9ae 100644 --- a/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonPathContentParser.java +++ b/liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/spi/solon/SolonPathContentParser.java @@ -39,7 +39,10 @@ public class SolonPathContentParser implements PathContentParser { @Override public List getFileAbsolutePath(List pathList) throws Exception { List allResource = getUrls(pathList); - return StreamUtil.of(allResource).map(URL::getPath).collect(Collectors.toList()); + return StreamUtil.of(allResource) + .map(URL::getPath) + .filter(FileUtil::isFile) + .collect(Collectors.toList()); } private static List getUrls(List pathList) throws MalformedURLException { @@ -57,14 +60,16 @@ public class SolonPathContentParser implements PathContentParser { path = path.substring(ResourceUtils.CLASSPATH_URL_PREFIX.length()); } - allResource.add(Utils.getResource(path)); + if (Utils.getResource(path) != null) { + allResource.add(Utils.getResource(path)); + } } } //如果有多个资源,检查资源都是同一个类型,如果出现不同类型的配置,则抛出错误提示 Set fileTypeSet = new HashSet<>(); allResource.forEach(resource -> fileTypeSet.add(FileUtil.extName(resource.getPath()))); - if (fileTypeSet.size() != 1) { + if (fileTypeSet.size() > 1) { throw new ConfigErrorException("config error,please use the same type of configuration"); } return allResource;