springboot swagger与thymeleaf冲突
springboot项目引入thymeleaf后,swagger访问报错
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Jun 15 14:04:24 CST 2022
There was an unexpected error (type=Not Found, status=404).
原因是thymeleaf默认的静态资源为classpath:/static/,而swagger-ui.html在别的路径,需要增加静态资源路径
解决方法
新建WebMvcConfigurer.java 继承 WebMvcConfigurationSupport, WebMvcConfigurer需要在ServletComponentScan包扫描范围
package com.base.config;