I am writing a spring boot based application and noticed a few warnings in chrome. It complains that for example web fonts (extension woff) are send as plain/text instead of
OK, found it myself :-)
In Spring boot you can customize the servlet container with this customizer and add new mimetypes there.
(UPDATE)
Spring-boot 2.x:
@Component
public class ServletCustomizer implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {
@Override
public void customize(TomcatServletWebServerFactory factory) {
MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
mappings.add("woff", "application/x-font-woff");
factory.setMimeMappings(mappings);
}
}
Spring-boot 1.x:
@Component
public class ServletCustomizer implements EmbeddedServletContainerCustomizer {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
mappings.add("woff","application/font-woff");
mappings.add("woff2","application/font-woff2");
container.setMimeMappings(mappings);
}
}