在配置跨域文件时 WebMvcConfigurer 报红
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("")
.allowedMethods(“GET”,“HEAD”,“POST”,“PUT”,“DELETE”)
.allowCredentials(true)
.maxAge(3600)
.allowedHeaders("");
}
原因为添加web依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>