spring boot 默認輸出spring的logo, 可使用spring.mvc.favicon.enabled=false
將其關閉spring
############################## thymeleaf ############################## spring.mvc.favicon.enabled=false spring.thymeleaf.cache=false # spring.thymeleaf.mode=HTML5 spring.thymeleaf.mode=LEGACYHTML5 ############################## thymeleaf ##############################
/** * Created by james.h.fu on 2017/09/19 */ @Configuration @Order(Ordered.HIGHEST_PRECEDENCE) public class WebConfig extends WebMvcConfigurerAdapter { @Autowired private AuthorizationInterceptor authorizationInterceptor; @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(authorizationInterceptor); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/static/**") .addResourceLocations("classpath:/static/"); } // @Bean // public FilterRegistrationBean corsFilter() { // UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); // CorsConfiguration config = new CorsConfiguration(); // config.setAllowCredentials(true); // config.addAllowedOrigin("*"); // config.addAllowedHeader("*"); // config.addAllowedMethod("*"); // config.setMaxAge(3600L); // source.registerCorsConfiguration("/api/**", config); // FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source)); // // 這個順序很重要哦,爲避免麻煩請設置在最前 // bean.setOrder(0); // return bean; // } @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/api/**") .allowedOrigins("*") .allowedMethods("GET", "POST", "OPTIONS") .allowedHeaders("*") .allowCredentials(true) .maxAge(3600); } }