zoukankan      html  css  js  c++  java
  • SpringBoot爬坑系列

    1.日志篇

    现象

    由于日志配置采用原来SpringMVC项目中的log4j.properties 文件,日志采用springboot自带的jar包会出现打印不出日志的情况。

    解决

    引入原日志包

    <slf4j.log4j12.version>1.7.21</slf4j.log4j12.version>
           
     <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${slf4j.log4j12.version}</version>
    </dependency>
    

    2. 拦截器篇

    现象

    支付宝异步调用的接口,进入方法前会被 LoginInterceptor-> postInitRequestInitHook中代码片段requetJSON == null 抛出异常,不能正确进入原方法体。
    代码片段:

    InputStream inputStream = request.getInputStream();
    String requestStr = IOUtils.toString(inputStream, "UTF-8");
    JSONObject requetJSON = JSONObject.parseObject(requestStr);
    if(requetJSON == null){
        throw new BusinessException(ResultCode.ILLEGAL_PARAMETER);
    }
    

    解决

    MyWebConfig -> addInterceptors 中 过滤支付宝异步通知的过滤 
    更新前

    registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/","/login/login","/index","/error");
    


    更新后

    registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/","/login/login","/index","/error","/alipay/alipayNotifyNotice");
    

    3. 签名篇

    现象

    支付宝异步通知中,有一个签名的过程。 
    签名:需要吧所有request里面的parameter加入算法中。 
    由于我们的框架中,在进入接口方法体之前,给request加入了2个parameter:correlationID、ipAddress。导致签名失败。

    结论

    调用类似的地方签名或者其他依赖入参的方法时,请注意我们框架自己定义的一些规则,以避免不必要的麻烦!

  • 相关阅读:
    KVM虚拟机高级设置——09 设置KVM虚拟机开机自动启动
    KVM虚拟机高级设置——08 管理远程虚拟机
    搭建KVM环境——07 带GUI的Linux上安装KVM图形界面管理工具
    搭建KVM环境——06 创建虚拟机
    TightVNC安装
    数据库设计
    Free lunch is over
    【问题】使用XShell连接Debian,没有语法高亮
    【Intel 汇编】ELF文件
    【问题】No manual entry for pthread_create in section 3
  • 原文地址:https://www.cnblogs.com/Profound/p/11187264.html
Copyright © 2011-2022 走看看