博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
解决:SpringBoot项目访问任意接口都跳转到login登录页面
阅读量:4046 次
发布时间:2019-05-25

本文共 809 字,大约阅读时间需要 2 分钟。

访问项目的任意接口,都会跳转到以下页面

但是项目中,并没有写过前端的页面。

想了想才发现,因为项目中用到了SpringSecurity,而SpringSecurity默认给我们加了一个用户认证的功能

用户名是:user   密码是在启动的控制台打印出来的:

解决方法: 

import org.springframework.context.annotation.Configuration;import org.springframework.security.config.annotation.web.builders.HttpSecurity;import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;@Configuration@EnableWebSecuritypublic class SecurityConfigSEVEN extends WebSecurityConfigurerAdapter {    @Override    protected void configure(HttpSecurity http) throws Exception {        //super.configure(http);        //配置不需要登陆验证        http.authorizeRequests().anyRequest().permitAll().and().logout().permitAll();    }}

写一个配置类,配置不需要登录验证就可以啦

转载地址:http://rnzci.baihongyu.com/

你可能感兴趣的文章
关于无人驾驶的过去、现在以及未来,看这篇文章就够了!
查看>>
所谓的进步和提升,就是完成认知升级
查看>>
为什么读了很多书,却学不到什么东西?
查看>>
长文干货:如何轻松应对工作中最棘手的13种场景?
查看>>
如何用好碎片化时间,让思维更有效率?
查看>>
No.147 - LeetCode1108
查看>>
No.174 - LeetCode1305 - 合并两个搜索树
查看>>
No.175 - LeetCode1306
查看>>
No.176 - LeetCode1309
查看>>
No.182 - LeetCode1325 - C指针的魅力
查看>>
mysql:sql alter database修改数据库字符集
查看>>
mysql:sql truncate (清除表数据)
查看>>
yuv to rgb 转换失败呀。天呀。谁来帮帮我呀。
查看>>
yuv420 format
查看>>
yuv420 还原为RGB图像
查看>>
LED恒流驱动芯片
查看>>
驱动TFT要SDRAM做为显示缓存
查看>>
使用file查看可执行文件的平台性,x86 or arm ?
查看>>
qt5 everywhere 编译summary
查看>>
qt 创建异形窗体
查看>>