Home > Spring > Spring Boot > Create a custom favicon in Spring Boot application

Create a custom favicon in Spring Boot application

In this article, we will learn how to configure custom favicon in the spring boot application. Favicon is the iconic representation of any website. It is placed in the address bar of any web browser. Spring boot provides option to create custom favicon for your website.

First create a favicon for your website, place it in the resources directory of your spring boot project inside a folder static. Path of the same is specified below.


Now in your WebMvc Configurer class place the below code to configure the custom resource.

public class WebConfig implements WebMvcConfigurer {

    public void addCorsMappings(CorsRegistry registry) {

    public void addResourceHandlers(ResourceHandlerRegistry registry) {

Now in your WebSecurityConfigurer class, permit the favicon URL, as mention below

public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
  protected void configure(HttpSecurity http) throws Exception { 

Now hit the favicon URL – http(s)://<Your-Domain>/favicon.ico