gateway如何引入common模块

来源:4-9 详解项目中增加网关模块

weixin_慕丝3459798

2023-12-15

直接引入common模块启动项目报错

Description:

Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.

Action:

Please set spring.main.web-application-type=reactive or remove spring-boot-starter-web dependency.

  1. 尝试设置spring.main.web-application-type=reactive, 会要求我配置数据库 报错如下
Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

2.排除common包下的springweb依赖
写法如下

		<dependency>
            <groupId>com.mooc</groupId>
            <artifactId>common</artifactId>
            <exclusions>
                <!-- Spring Cloud Gateway 项目中不能使用 spring-boot-starter-web 依赖-->
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

报错
图片描述
gateway依赖如下
图片描述

写回答

1回答

甲蛙

2023-12-18

gateway不需要引入common模块,我课程里也没引入 

0
2
甲蛙
回复
weixin_慕丝3459798
这种情况最好是直接在gateway里新增一个CommonResp类。
2023-12-20
共2条回复

新版Springboot3.0打造能落地的高并发仿12306售票系统

最新版Spring3.0仿12306售票系统实战

852 学习 · 511 问题

查看课程