Guide to Custom the Favicon in Spring Boot

2016-08-12


A favicon is a small website icon displayed in a browser, usually next to an address.
Often we don’t want to settle for the default ones provided by various frameworks such a Spring Boot.
In this quick tutorial, we’ll discuss how to customize the favicon of a Spring Boot application, by looking into various approaches to customizing the favicon.

Solution

Disabling the default favicon setting

first of all, disabling the default favicon in our application.properties file:

spring.mvc.favicon.enabled=false

or application.yml file:

spring:
  mvc:
    favicon:
      enabled: false

Disabling the default favicon setting

The simplest way to override the default favicon of a Spring Boot application is to place the new favicon in the resources directory:

src/main/resources/favicon.ico

Putting favicon.ico in the root level of resources directory

The favicon file should have the favicon.ico name.
We may also put that file in the static directory inside project’s resources directory:

src/main/resources/static/favicon.ico

Spring Boot while starting up, scans for the favicon.ico file in the root resources location followed by static content locations.

Instead of putting the favicon in the root level of resources directory, we might want to keep it along with other images of the application. page link:

<link rel="icon" type="image/x-icon" href="/static/favicon.ico">

Reference

Guide to the Favicon in Spring Boot
SpringBoot自定义favicon.ico(含源码)
springboot自定义favicon.ico

Comments
Write a Comment