每一秒钟的时间都值得铭记

0%

SpringBoot整合FreeMarker模板报错

DefaultObjectWrapper.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.
Configuration.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.

该报错的原因是因为没有指定对应的FreeMarker版本,而之前通过Configuration.getVersion()方式获取版本号已经不推荐使用,目前使用新的方式获取版本号。

之前的版本号获取方式:

1
Configuration cfg = new Configuration(Configuration.getVersion());

修改之后的版本号获取方式:

1
Configuration cfg = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);

或者,如果开发者清楚知道项目中使用的FreeMarker版本的话,也可以直接指定版本号即可:

1
Configuration cfg = new Configuration(Configuration.VERSION_2_3_30);

根据报错信息提示,该报错在2.4.0之前的版本中并不会对FreeMarker模板的功能有什么影响,但是在2.4.0版本之后可能会不推荐使用这种方法设置版本号。所以建议使用FreeMarker新的版本号获取方式。

坚持原创技术分享,您的支持将鼓励我继续创作!
-------------这是我的底线^_^-------------