Open little-pinecone opened 3 years ago
Good find, there are some issues in versions 0.7.2 and earlier when it comes to using Dummy4j in jars.
I have fixed this in version 0.7.3, at least mostly. There should now be no issues when using Dummy4j in Spring Boot. Unfortunately, I had to hardcode the "BOOT-INF/classes/" prefix, as I could not figure out a better solution for the time being.
While this issue is fixed, I will leave this issue open for now, to act as a reminder that the resource loading code needs some refactoring.
As for the refactoring, an idea to pursue could be to use the ResourceStreamProvider::get
method to get a list of all files in the client's classpath (and somehow try to get their prefix), but that's for another day.
Example application: efficient-mvp-example
After building application with the following command:
and making the
http://localhost:8080/api/init?seed=1&how-many-books=100
request I'm gettingMissingLocaleException
.The logs show:
Loading definitions from: [BOOT-INF/classes/dummy4j/en/book.yml]
instead ofLoading definitions from: [dummy4j/en/book.yml, …]
Adding another condition specifically for Spring Boot projects in
YamlFileLoader::isInAllowedPath
seems to fix the problem, but there must be a better way that doesn't require hardcoding:Useful links: Resource pattern filter for complete resource path #148