今天建了一个初始项目,引入swagger之后,启动调用,却总跳转到一个登录页面,手足无措
最后原因是导入了security的包,导致权限安全拦截
注释后运行成功,如果没有成功看一下dependencies 里面是否还存在security包,可能没有删除掉
当要存在security
添加SecurityConfig类
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;/*** @Author plj* @Date 2022/8/5 16:40*/
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {@Overridepublic void configure(WebSecurity web) throws Exception {//忽略对以下地址的安全校验 加入你不想security校验的接口即可web.ignoring().antMatchers("/login","/logout","/css/**","/js/**","/index.html","favicon.ico","/doc.html","/webjars/**","/swagger-resource/**","/v2/api-docs/**");}
}