-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Freemarker is configured to prefer filesystem access by default #23051
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
Thanks for the report but this is working as documented. Templates are picked up from a single directory so you creating an extra one means Spring Boot will look there and only there. There is a note in the documentation that hints you at using |
src/test/resources/templates
exists
Thanks for the swift response and link to the docs, makes sense. Couldn't actually get the demo test to pass using |
Sorry for overlooking the sample. That is interesting and it looks like it is Freemarker specific. I'll have to dig in a little bit more and we can requalify this issue accordingly. Given the loader is in the spring framework we may also create an issue there if need to be.
Regardless of fixing this issue, I find that setup more explicit. |
So with the help of @jhoeller I've been able to dig into this problem. The core framework support of Freemarker default to look for a single directory if available (see This flag is Also, the notes that I've shared above doesn't qualify for Freemarker at least. Freemarker will ignore |
The documentation note was added in the fix for #2319 |
There is actual a property that controls this that was introduced in #2901 @halfninja I've added |
If I write a test that loads a template under
src/main/resources/templates
it works fine. If I then create a template undersrc/test/resources/templates
the test then fails as the template loader switches to looking there and only there. It's useful to be able to have a test template to check the behaviour of any custom Freemarker settings.Ideally it would load from all
templates
resources found on the classpath, not just one.Project to reproduce the problem (Spring Boot 2.4.0-M2):
https://github.com/halfninja/spring-ftl-bug-repro
Renaming
src/test/resources/templates
causes the test to pass.The text was updated successfully, but these errors were encountered: