ZPY博客

Spring Cloud Gateway与spring-boot-starter-web冲突

大家应该都知道,Spring Cloud Gatewayspring-boot-starter-web有冲突,一般情况下我们只需要把spring-boot-starter-web依赖去掉即可。

但是现在的情况是,Spring Cloud Gateway工程里引入了一个common包,common包里又加了spring-boot-starter-web依赖,所以无法直接删除依赖。解决方法如下:

在引入common包里加上exclusions来去掉spring-boot-starter-web依赖。

<dependency>
            <groupId>com.xxx</groupId>
            <artifactId>xxx-common</artifactId>
            <version>0.0.1-SNAPSHOT</version>
      <exclusions>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
        </exclusion>
      </exclusions>
        </dependency>