@CrossOrigin(allowCredentials = "true",allowedHeaders = "*") 總是報錯
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.
2022-08-14
在最新的?2.5.2?版本中,使用這種方式運行項目會報錯,使用了 allowCredentials = “true” 之后,不可以把origin設(shè)置為*(即默認(rèn)狀態(tài))。
如果在IDEA里運行可以加上域名否則就用第二行的