您可以将自己的favicon.ico放在类路径的根目录或任何静态资源位置(例如
classpath:/static)中。您也可以使用单个标志完全禁用Favicon分辨率
spring.mvc.favicon.enabled=false。
或者,要完全控制,可以添加一个HandlerMapping(只需从Boot复制一个并赋予其更高的优先级),例如
@Configurationpublic static class FaviconConfiguration {@Beanpublic SimpleUrlHandlerMapping faviconHandlerMapping() { SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping(); mapping.setOrder(Integer.MIN_VALUE); mapping.setUrlMap(Collections.singletonMap("mylocation/favicon.ico", faviconRequestHandler())); return mapping;}@Beanprotected ResourceHttpRequestHandler faviconRequestHandler() { ResourceHttpRequestHandler requestHandler = new ResourceHttpRequestHandler(); requestHandler.setLocations(Arrays .<Resource> asList(new ClassPathResource("/"))); return requestHandler;}}


