SpringCloudGateway中出现No primary or default constructor和web-application-type=reactive or remove

简介: SpringCloudGateway中出现No primary or default constructor和web-application-type=reactive or remove

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

 

报错2:No primary or default constructor found for interface javax.servlet.http.HttpServletRequest。java.lang.NoSuchMethodException: javax.servlet.http.HttpServletResponse

 

一开始我是先报错1,然后就通过,在yml 配置文件中配置以下代码即可。或者在pom文件里注释掉spring-boot-starter-web的依赖

main:
    web-application-type: reactive

后面出现了报错2,在使用HttpServletResponse或HttpServletRequest方法的时候说没该方法。这时候我就想到了会不会是版本问题,但总的来想是不大可能的。毕竟别人导入的依赖是一样也可以。后面想到gateway组件中的spring-boot-starter-webflux也是有web功能但没有这个方法,而我傻逼的是把这个gateway组件放在了父类项目的pom中......(实际应该放在gateway项目中让gateway项目用他自己那套webflux),因为之前我已经在yml中把spring-boot-starter-web注释掉了这样就导致了只用了gateway网关的web发生没有这个方法的报错。

总的来说是:

在controller的接口类的方法参数中使用HttpServletResponse或HttpServletRequest作为参数的时候要用到spring-boot-starter-web依赖,但是一旦修改为了spring-boot-starter-webflux依赖,那么就不能再方法参数中使用HttpServletResponse或HttpServletRequest了。

且gateway组件放在父类项目且父类项目有中spring-boot-starter-web组件的话则会发生冲突

目录
相关文章
|
2天前
|
JavaScript
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
89 0
|
2天前
|
前端开发 开发者
TS7031: Binding element ‘role‘ implicitly has an ‘any‘ type.
TS7031: Binding element ‘role‘ implicitly has an ‘any‘ type.
53 1
|
9月前
|
JavaScript 前端开发
成功解决Component template should contain exactly one root element
成功解决Component template should contain exactly one root element
|
存储 小程序
【小程序】自定义组件的data、methods、properties
【小程序】自定义组件的data、methods、properties
304 0
【小程序】自定义组件的data、methods、properties
|
Java 开发工具
gradle Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.crea
gradle Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.createCrossBuildFileHashCache().
6662 0
vue+ts:Property ‘searchMes‘ is private and only accessible within class ‘HomeComponent‘.
vue+ts:Property ‘searchMes‘ is private and only accessible within class ‘HomeComponent‘.
168 0
vue+ts:Property ‘searchMes‘ is private and only accessible within class ‘HomeComponent‘.
No injector for custom defined data type的解决办法
No injector for custom defined data type的解决办法
225 0
No injector for custom defined data type的解决办法
SAP Spartacus lazy load 的一个例子 - User Module
SAP Spartacus lazy load 的一个例子 - User Module
87 0
SAP Spartacus lazy load 的一个例子 - User Module
Step by step to create web service in Cloud Application studio and bind it to a custom action in sta
I woud like to change this extension field in third party system outside C4C, using web service or OData service. I have created a new action in BO CustomerQuote:
Step by step to create web service in Cloud Application studio and bind it to a custom action in sta