|
@@ -16,6 +16,11 @@
|
|
|
package com.baomidou.mybatisplus.autoconfigure;
|
|
|
|
|
|
|
|
|
+import org.apache.ibatis.io.VFS;
|
|
|
+import org.springframework.core.io.Resource;
|
|
|
+import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
|
|
+import org.springframework.core.io.support.ResourcePatternResolver;
|
|
|
+
|
|
|
import java.io.IOException;
|
|
|
import java.io.UncheckedIOException;
|
|
|
import java.net.URL;
|
|
@@ -23,12 +28,6 @@ import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
-import org.apache.ibatis.io.VFS;
|
|
|
-
|
|
|
-import org.springframework.core.io.Resource;
|
|
|
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
|
|
-import org.springframework.core.io.support.ResourcePatternResolver;
|
|
|
-
|
|
|
/**
|
|
|
* @author Hans Westerbeek
|
|
|
* @author Eddú Meléndez
|
|
@@ -49,20 +48,20 @@ public class SpringBootVFS extends VFS {
|
|
|
|
|
|
@Override
|
|
|
protected List<String> list(URL url, String path) throws IOException {
|
|
|
- Resource[] resources = resourceResolver.getResources("classpath*:" + path + "/**/*.class");
|
|
|
+ String urlString = url.toString();
|
|
|
+ String baseUrlString = urlString.endsWith("/") ? urlString : urlString.concat("/");
|
|
|
+ Resource[] resources = resourceResolver.getResources(baseUrlString + "**/*.class");
|
|
|
return Stream.of(resources)
|
|
|
- .map(resource -> preserveSubpackageName(resource, path))
|
|
|
+ .map(resource -> preserveSubpackageName(baseUrlString, resource, path))
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- private static String preserveSubpackageName(final Resource resource, final String rootPath) {
|
|
|
+ private String preserveSubpackageName(final String baseUrlString, final Resource resource, final String rootPath) {
|
|
|
try {
|
|
|
- final String uriStr = resource.getURI().toString();
|
|
|
- final int start = uriStr.indexOf(rootPath);
|
|
|
- return uriStr.substring(start);
|
|
|
+ return rootPath + (rootPath.endsWith("/") ? "" : "/")
|
|
|
+ + resource.getURL().toString().substring(baseUrlString.length());
|
|
|
} catch (IOException e) {
|
|
|
throw new UncheckedIOException(e);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|