慕粉0834181895
2021-08-16 21:16
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: When allowCredentials is true, allowedOrigins cannot contain the special value "*" since that cannot be set on the "Access-Control-Allow-Origin" response header. To allow credentials to a set of origins, list them explicitly or consider using "allowedOriginPatterns" instead.
在最新的 2.5.2 版本中,使用这种方式运行项目会报错,使用了 allowCredentials = “true” 之后,不可以把origin设置为*(即默认状态)。
如果在IDEA里运行可以加上域名否则就用第二行的
@CrossOrigin(origins = "http://localhost:63342",allowCredentials = "true",allowedHeaders = "*") @CrossOrigin(origins = {" * "}, allowedHeaders="*")
SpringBoot构建电商基础秒杀项目
49064 学习 · 954 问题
相似问题