这个测试用例很顺利就搬过来了。只有一个坑,判断了是否存在WebSecurityConfigurer类,需要引入依赖spring-boot-starter-security。
public Set<String> getIgnoredHeaders() { Set<String> ignoredHeaders = new LinkedHashSet<>(this.ignoredHeaders); if (ClassUtils.isPresent( "org.springframework.security.config.annotation.web.WebSecurityConfigurer", null) && Collections.disjoint(ignoredHeaders, SECURITY_HEADERS) && ignoreSecurityHeaders) { // Allow Spring Security in the gateway to control these headers ignoredHeaders.addAll(SECURITY_HEADERS); } return ignoredHeaders; }