本文共 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/