I know this question has been asked over and over here and there are several solutions. I've tried several of those except the ones that suggests writing you own configuration bean for this. I don't want to do all that just to display a tiny icon it seams overkill. But I can not get it to work. These are the solutions I've tried so far.
<link rel="icon" type="image/png" href="favicon.png" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
Neither of those work.
When inspecting the page in the browser I sometimes get no error at all printed out despite no icon showing, or I get an error saying GET http://localhost:8080/myapp/favicon.png 404 ()
Where it is refering the type as JSON (which I find strange).
I'm running out of ideas here so if anyone can tell me why this is not working please let me know. Did I perhaps forget one of those magic spring annotations? This is what my main class looks like.
@SpringBootApplication
@ComponentScan
@Configuration
@EnableWebMvc
public class JobengineMonitorApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(JobengineMonitorApplication.class, args);
}
}
I am using thymeleaf as the template engine
Put your favicon.png
under src/main/resources/public
and add this to your *.html
page exactly in the header
section
<link rel="shortcut icon" type="image/png" th:href="@{favicon.png}"/>
I saved my favicon which was a simple .png download as src/main/resources/static/favicon.ico
I couldn't get it to display until I tried another browser and it worked fine - so try clearing the browser cache, or try testing on another browser
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With