在写springboot跨域配置时,遇到了如下报错
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
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.
报错的解决办法
查看你的pom.xml文件,看你的springboot版本是否是2.4之后的,如果是,可以将其改为2.4之前的版本,这种方式解决了我的问题。我之前的是2.5的版本,改为2.2.6版本后可以
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>