Change favIcon vaadin 24.3.13

Hello!
I have a problem with favicon in Vaadin 24.3.13. I put the icon in “src/main/resources/META-INF/myfavicon.ico” (Is the right path?) and I have this code in my class:

public void configurePage(AppShellSettings settings) {
settings.addFavIcon(“icon”, “myfavicon.ico”, “192x192”);
settings.addLink(“shortcut icon”, “myfavicon.ico”);
}

But nothing happens. The default vaadin icon still showing. I don’t know what I am doing wrong. Thanks in advance. Regards.

The path you have is correct, but the icon name needs to be favicon.ico. If you name it that, it will be picked up automatically, no need for the configurePage override.

Hello Marcus.
Sorry, but it doesn’t work for me.
I have Vaadin updated to 24.3.13
Favicon is on path src/main/resources/META-INF/favicon.ico
Favicon is 32x32 ICO file with 32 bit color depth
I haven’t made any changes in configurePage
I have re-packaged app in production mode, cleared browser cache, tried Opera and Firefox, but still no custom favicon.

Thanks for your advice …

It doesn’t work for me either. I have the same config than @fedorko

The answer to this questions always depends a bit on your application. If you have WAR packaged Spring Boot app, the default place of faicon.ico is here:

image

In my case I have a JAR packaged Spring Boot app. What would be the path?. Thanks for supporting.

In JAR package src/main/webapp is not used. You should use e.g. /src/main/resources/static or /src/main/resources/META-INF/resources

/src/main/resources/META-INF/resources doesn’t work, either. Is there a working example with favicon.ico working?

/src/main/resources/META-INF/resources works for me. If I put the icon in /src/main/resources/META-INF/resources/myfavicon.ico and add the following code to the AppShellConfigurator implementor, it is correctly rendered

    @Override
    public void configurePage(AppShellSettings settings) {
        settings.addFavIcon("icon", "myfavicon.ico", "192x192");
        settings.addLink("shortcut icon", "myfavicon.ico");
    }

Did you try to access the icon directly from the browser (e.g. http://localhost:8080/myfavicon.ico) to check if it is reachable?
Could it be some cache issue on the browser?

1 Like

Solved using AppShellConfigurator.
Similar to Marco’s solution, but icon is in different directory and different type.
Application is packaged as fat-jar, did’n tried war files.

I used SVG file placed in static resource directory :

src/main/resources/static/Tangram_logo.svg

Then I applied AppShellConfigurator to my SpringBoot starting class:

package tangram;

import com.vaadin.flow.component.page.AppShellConfigurator;
import com.vaadin.flow.server.AppShellSettings;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
// @ComponentScan(basePackages = {"tangram"})
public class ApplicationStart implements AppShellConfigurator
{
	public static void main(String[] args)
	{
		SpringApplication.run(ApplicationStart.class, args);
	}

	@Override public void configurePage(AppShellSettings settings)
	{
		settings.setPageTitle("Tangram Customer Portal");
		settings.addFavIcon("icon", "Tangram_logo.svg", "64x64");
	}
}