package com.demo.configimport org.springframework.context.annotation.Configurationimport org.springframework.web.servlet.config.annotation.CorsRegistryimport org.springframework.web.servlet.config.annotation.InterceptorRegistryimport org.springframework.web.servlet.config.annotation.WebMvcConfigurer@Configurationopen class WebMvcContext : WebMvcConfigurer { /** * cors 跨域支持 */ override fun addCorsMappings(registry: CorsRegistry) { registry.addMapping("/**") //设置允许跨域请求的域名 .allowedOrigins("*") //设置允许的方法 .allowedMethods("*") //设置允许的头信息 .allowedHeaders("*") //是否允许证书 不再默认开启 .allowCredentials(java.lang.Boolean.TRUE); }}