SpringBoot启动新项目,报401错误,但是项目并不需要登录
原因:
SpringBoot项目中只要引入了spring-boot-starter-security包,默认就已经开启了权限认证。
解决方案:
这么几种方式可以解决:
1.删除spring-security相关的pom引入,如下:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>
2.通过在SpringBootApplication中添加exclude,禁用security
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class})