-
Notifications
You must be signed in to change notification settings - Fork 41.2k
PathMatchingResourcePatternResolver can not work in spring boot 1.4.0.RELEASE when package a executable jar #7003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@peace0phmind Can you provide a sample that reproduces the problem please? I'd like to be able to see the exact layout of your projects and exactly where the mapper files are. We also need to know how you're running your application. In your IDE, using Maven or Gradle, as a fat jar, something else? |
Here is my sample: https://github.com/peace0phmind/spring-boot-mybatis-sample mvn clean package you will get an error output log: 2016-09-23 17:39:19.238 ERROR 27684 --- [ main] com.sample.Application : resources is null. but, when you change spring boot version in the pom to 1.3.0.RELEASE, and do it again, it is ok. |
Thanks for the sample. The problem's a result of the location pattern that you're using:
The
This works in both 1.3 and 1.4. The original location pattern works in 1.3 because of the hack that was added to fix #420. It was subsequently removed in 1.4 as part of cleaning up the delegation model of Boot's class loader (87fe0b2). |
It also works (in 1.3 and 1.4) with the original location pattern when the jar is shaded, but only due to this logic in
With a shaded jar run with The behaviour of the system class loader is why the hack that was added to #420 was removed as it made our class loader behave in a non-standard way as it would return URLs for all of the jar roots on the class path. However, I think we need to update |
I have a possible fix for this. @philwebb Could you please take a look and see if it seems like a reasonable change to you? |
Get it, Thanks. Because in my real product, i have mybatis and mybatis-generator in the classpath, so i use the mybatis* instead. |
My proposed fix will require #7021 to be fixed as well |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I'm using spring boot 1.3.0.RELEASE and using
PathMatchingResourcePatternResolver
to find mybatis mapper files with under code:It works fine under 1.3.0.RELEASE. For some reason I upgrade spring boot to 1.4.0.RELEASE, then it can not work.
I debug into the source ,find the code in PathMatchingResourcePatternResolver:
The different between 1.4.0 and 1.3.0, the 'resourceUrls.hasMoreElements()' returned false and true.It seems that 'cl.getResources(path)' returned different object.
So, why this happened and how to resolve it?
The text was updated successfully, but these errors were encountered: