zoukankan      html  css  js  c++  java
  • feign.FeignException$NotFound: [404] during [GET] to [http://127.0.0.1:8011/csm/api/v1.0/system/platform/test] [SysPlatformIf#querySysManagerIp()]: [{"timestamp":1583803232721,"status":

    feign,404的问题个人理解:

    第一种:请求从本模块中没法出去;

    第二种:请求出去,没进入另一个模块。

    因为本项目是springboot在父模块下的多个子模块之间使用feign的调用,且项目最终打成一个jar包发布,所以在开发中遇见的问题如下:

    第一:请求没法出去、这里没法出去的原因有很多,比如地址以及端口号没配置正确

     比如网上说的不能使用GetMapping()注解之类的,但是在这里好像是可以,有可能是版本不一样,更新了吧;

     上面这个会出现的问题有url的路径问题,啥的;反正正常通过ip以及端口发出去就行;

    第二种就是进不去:进不去;

    我现在遇到的问题是系统登陆之后;通过页面可以访问该接口,但是在系统内部相互调用的时候,会出现问题,啥子原因呢?后来找到的结果是,给feign添加了token信息,也就是说在对另一个模块请求的时候进行了拦截,未登录,所以会出现了这个情况,具体添加配置如下:

    import feign.RequestInterceptor;
    import feign.RequestTemplate;
    import org.springframework.context.annotation.Configuration;
    import org.springframework.web.context.request.RequestContextHolder;
    import org.springframework.web.context.request.ServletRequestAttributes;
    
    import javax.servlet.http.HttpServletRequest;
    
    /**
     * 跨模块获取登录信息
     * author 
     * date 2020/2/20 0020 16:11
     */
    @Configuration
    public class FeignConfig implements RequestInterceptor {
        @Override
        public void apply(RequestTemplate requestTemplate) {
            ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
    
            HttpServletRequest request = requestAttributes.getRequest();
            requestTemplate.header("postman-token",request.getHeader("postman-token"));
            requestTemplate.header("cookie",request.getHeader("cookie"));
        }
    }

     这里有一个额外的例子。可以看看:https://www.cnblogs.com/ft535535/p/9898147.html

  • 相关阅读:
    Mycat学习笔记 第三篇. MySql 主从同步异常后,主从切换
    【转】MYSQL主从同步故障一例及解决过程!
    Mycat学习笔记 第二篇. MySql 读写分离与日志分析——主从多结点
    Mycat学习笔记 第一篇. MySql 读写分离与日志分析——主从单结点
    Leetcode 172 Factorial Trailing Zeroes
    Leetcode 7 Reverse Integer
    Leetcode 2 Add Two Numbers
    Leetcode 83 Remove Duplicates from Sorted List (快慢指针)
    Leetcode 141 Linked List Cycle(快慢指针)
    Leetcode 21 Merge Two Sorted Lists
  • 原文地址:https://www.cnblogs.com/notchangeworld/p/12460579.html
Copyright © 2011-2022 走看看