Hi,
When using Spring Boot 2.3.1 with Freemarker (so the version of Freemarker is 2.3.30) I got this error in console log :
2020-06-30 10:23:43,243 ERROR [freemarker.beans] (default task-7) BeansWrapper.incompatibleImprovements was set to the object returned by Configuration.getVersion(). That defeats the purpose of incompatibleImprovements, and makes upgrading FreeMarker a potentially breaking change. Also, this probably won't be allowed starting from 2.4.0. Instead, set incompatibleImprovements to the highest concrete version that's known to be compatible with your application.
It's shown for every page, it's just a log but it's annoying AND it indicate that a futur version of Freemarker will not continue to work ...
I tried to use Spring Boot 2.2.8 but it's the same thing.
To resolve my issue I finally forced the freemarker version to be 2.3.29 by using this in pom.xml :
<properties>
<freemarker.version>2.3.29</freemarker.version>
</properties>
It would be nice if the problem is corrected in a futur version. Thank you.
Comment From: wilkinsona
Thanks for the report. Unfortunately, I cannot reproduce the behaviour you have described. No errors are logged when running of Freemarker smoke test application, and debugging it shows that the incompatible improvements version is 2.3.0 while the configuration version is 2.3.30. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.
Comment From: pgervaise
I reduced my enterprise project to the strict minimum (and without personal informations) and I obtained a mini-project where the problem occurs.
The code source is available here : https://github.com/pgervaise/web-planning-test-freemarker
When using spring boot 2.2.5 : no warning (because of Freemarker 2.3.29) When using spring boot 2.2.8 or 2.3.1 : there is a warning (because of Freemarker 2.3.30)
I discovered that it's inherited by the class FreemarkerConfig when configuring Freemarker for Spring Boot. The warning is generated by the class PlanningFreeMarkerView at line 29.
I guess it should have a trick to do the same thing in the right way (for freemarker 2.3.30+).
Comment From: wilkinsona
Thanks for the sample. The behaviour that you are seeing is due to this change in FreeMarker 2.3.30 and how you're creating the BeansWrapperBuilder:
BeansWrapper wrapper = new BeansWrapperBuilder(Configuration.getVersion()).build();
As recommended in FreeMarker's javadoc, you should pass in a fixed version rather than what's returned from Configuration.getVersion()
.
Comment From: pgervaise
Thank you for your help.
I changed Configuration.getVersion()
by new Version(Configuration.getVersion().toString())
and it works.
It's a little bit tricky but it let Spring MVC managing the version of freemarker used. Found it in Spring Context Support / FreeMarkerConfigurationFactory class.