原因:
gateway
引入了自定义的common
包.
里边定义了统一返回值处理方法
@RestControllerAdvice(basePackages = {"com.*"}) // 这里要加上需要扫描的包
public class ResponseControllerAdvice implements ResponseBodyAdvice<Object> {
}
因为gateway
不能使用web-starter
所以报ResponseBodyAdvice找不到
这个错误
修改结果
- 方法1
@RestControllerAdvice(basePackages = {"com.*"}) // 这里要加上需要扫描的包
@ConditionalOnClass(ResponseBodyAdvice.class)
public class ResponseControllerAdvice implements ResponseBodyAdvice<Object> {
}
- 方法2
将gateway
的启动类放到与其他代码不一样的路径下边
如:
gateway
启动类路径为com.a.GatewayApplication.java
common
包的路径为com.b.*.ResponseControllerAdvice .java