- 注意: 如果网关使用的是Gateway 进来不要设置cntextPath
- 在测试 业务服务配置了 context-path 后,gateway无法访问业务服务中出现了 openfeign 也调用失败
HTTP Status 404 – Not Found
- 因为加入了 context-path 后,访问是就得必须加上他,所以解决方法如下
被访问的项目配置
server:port: 1003 #端口servlet:context-path: /basic
访问项目的 openFeign 修改配置为
import org.springframework.cloud.openfeign.FeignClient;import org.springframework.web.bind.annotation.GetMapping;/*** 调用server-basic的feign层* @author tn* @version 1* @ClassName ServerBasicFeign* @description rpc Server* @date 2020/8/6 19:33*/@FeignClient(name = "server-basic")//@FeignClient(name = "server-basic/basic")//可以这样设置全局public interface ServerBasicFeign {/*** basic项目没有配置 context-path 时*/@GetMapping(value = "openFeign/test01")String test01();/*** basic项目配置了 context-path 时*/@GetMapping(value = "basic/openFeign/test01")String test01();}
