博主最近在整合单体项目swagger和shiro的时候遇到一个坑。
pom和shiro,swagger的配置文件都配好了的情况下,访问
http://localhost:8080/swagger-ui.html
一直是Whitelabel Error Page 404 纳闷,之前因为没遇到过这个问题,
百度之后发现,项目中有web配置,因此怀疑是这些配置影响了,
所以加上了,
package com.leigq.www.shiro.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
重新启动,完美解决。