Reputation: 452
I want to change the favicon of the website in Vaadin that is combined with Springboot. I have also opted to go the pure Java route within Vaadin (no html page).
I followed this guide, which explains that the icon I wish to use should be added in the src/main/webapp/icons
folder where it will be automatically picked up, resized, etc.
I tried that to no avail, after which I found this thread and subsequently this one. The latter link especially explains that Spring-boot has its own directories and that the webapp
folder should be avoided. I tried using the spring directories, but again to no avail.
My resources folder currently looks as such:
My MainView as such:
@Route
@PageTitle("My new title")
public class MainView extends VerticalLayout {
And my SpringBootApplication
class as such:
@SpringBootApplication
public class MyVaadinApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(MyVaadinApplication.class, args);
}
}
The icon still remains the default spring leaf:
Where am I going wrong in trying to set the favicon?
Upvotes: 3
Views: 1021
Reputation: 326
Add icon.png
to resources/META-INF/resources/icons/icon.png
Then:
@PWA
annotation) it should already workPageConfiguration
and add link to your favicon.@Route("favicon")
public class FaviconTest extends Div implements PageConfigurator {
@Override
public void configurePage(InitialPageSettings settings) {
HashMap<String, String> attributes = new HashMap<>();
attributes.put("rel", "shortcut icon");
attributes.put("type", "image/png");
settings.addLink("icons/icon.png", attributes);
}
}
Upvotes: 7