Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2017 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,13 +16,11 @@
package org.mybatis.spring.boot.autoconfigure;

import java.io.IOException;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

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;
Expand All @@ -47,18 +45,20 @@ public boolean isValid() {

@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");
List<String> resourcePaths = new ArrayList<String>();
for (Resource resource : resources) {
resourcePaths.add(preserveSubpackageName(resource.getURI(), path));
resourcePaths.add(preserveSubpackageName(baseUrlString, resource, path));
}
return resourcePaths;
}

private static String preserveSubpackageName(final URI uri, final String rootPath) {
final String uriStr = uri.toString();
final int start = uriStr.indexOf(rootPath);
return uriStr.substring(start);
private static String preserveSubpackageName(
final String baseUrlString, final Resource resource, final String rootPath) throws IOException {
return rootPath + (rootPath.endsWith("/") ? "" : "/")
+ resource.getURL().toString().substring(baseUrlString.length());
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2015-2018 the original author or authors.
* Copyright 2015-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -280,7 +280,7 @@ public void testMixedWithConfigurationFileAndTypeHandlersPackage() {
EnvironmentTestUtils
.addEnvironment(this.context,
"mybatis.config-location:mybatis-config-settings-only.xml",
"mybatis.type-handlers-package:org.mybatis.spring.boot.autoconfigure.handler");
"mybatis.type-handlers-package:org.mybatis.spring.boot.autoconfigure.handler.");
this.context.register(EmbeddedDataSourceConfiguration.class,
MybatisBootMapperScanAutoConfiguration.class);
this.context.refresh();
Expand Down