偶然发现不管我将spring.mvc.favicon.enabled设置成true还是false,系统表面上都没有什么变化。favicon该显示还是显示。

那么这个配置究竟有什么用呢?

我在github的issue找到了答案。

It only disables serving a favicon.ico from the root of the classpath. A favicon.ico that’s placed in one of the static resource locations will still be served.

也就是说将spring.mvc.favicon.enabled设置成false,只是让classpath下的favicon图标不能用。而static下的favicon仍然可以用。

WebMvcAutoConfigurationFaviconConfiguration也可以验证这一点。

favicon的请求是由浏览器发起的,所以如果要禁用需要让系统不再请求这个图标。