Spring-Security取消验证-Get请求接口正常,Post请求报错403

现象:springcloud项目夹带security相关的包后启动提示如下:

Using generated security password: f67f9afa-xxxxxxxxxxx-a85e-88175f5a7c8a

This generated password is for development use only. Your security configuration must be updated before running your application in production.

一眼看上去项目中带有Spring-Security相关包,经过maven依赖查看后加了exclude排除,但是问题依然存在:

        Get请求接口正常,Post请求报错403.

于是乎加入WebSecurityConfig才屏蔽了验证,代码如下:

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().anyRequest().permitAll().and().csrf().disable();
    }
}

通常,禁用spring security两种方法:

@EnableAutoConfiguration(exclude = {SecurityAutoConfiguration.class})
或者

@SpringBootApplication(exclude = {SecurityAutoConfiguration.class })