最近工作中遇到的4个问题

    xiaoxiao2022-07-02  119

    1、linux 时间同步当前时间 系统时间提前或延迟,给排查问题,带来很大干扰。 尤其是看到 提前到来的时间,比如2020年,怀疑人生。

    linux展示日期,设置格式 date +"%Y-%m-%d %H:%m:%S"

    设置时间和日期 例如:将系统日期设定成2009年11月3日的命令 命令 : date -s 05/20/2019 将系统时间设定成下午5点55分55秒的命令 命令 : date -s 20:12:43

    本来打算,执行下时间同步器,网上找了下,有点复杂,还不如手动修改。

    2.记录日志经常犯的一个错误 void org.slf4j.Logger.error(String msg, Throwable t) 错误写法:log.error("获取账单分页失败,异常信息={}.", e); 正确写法:log.error("获取账单分页失败,异常信息.", e);  

    3.联想电脑和联想鼠标,无线的,用起来舒服,就是容易遇到问题。 最近,越来越频繁,需要手动打开开关。 今天,突然发现,可能是电池不足了。 正好隔壁有几个没人用的鼠标,把里面的电池拿出来,替换下,就好了。 不过,同时发现,鼠标和电脑还是绑定的,不能用其他人的无线鼠标,指挥自己的电脑。 真不喜欢用无线的鼠标。

    4、SpringMVC,controller里注入service奇葩bug DictionaryController 3个方法,2个private,1个public。 有public方法的时候,如果访问private方法,会提示 dictionaryService空指针。 现象:有public方法的时候,private不会自动注入service。 坑死人。 正常对外代码,就不应该用 private。错误的写法

    @RestController @RequestMapping("manage/dictionary") public class DictionaryController extends BaseController{     @Resource     private DictionaryService dictionaryService;     @RequestMapping("/getDictionary")     private String getDictionary(Dictionary dictionary){     }          @RequestMapping("/getInvoiceCheckConfig")     private String getInvoiceCheckConfig(){     }          @RequestMapping("/payeeList")     public String payeeList(){     }      }

    正确的写法(不建议这么写)

    @RestController @RequestMapping("manage/dictionary") public class DictionaryController extends BaseController{     @Resource     private DictionaryService dictionaryService;     @RequestMapping("/getDictionary")     private String getDictionary(Dictionary dictionary){     }          @RequestMapping("/getInvoiceCheckConfig")     private String getInvoiceCheckConfig(){     }          @RequestMapping("/payeeList")     private String payeeList(){     }      }

    正确的写法(建议都使用public修饰符)

    @RestController @RequestMapping("manage/dictionary") public class DictionaryController extends BaseController{     @Resource     private DictionaryService dictionaryService;     @RequestMapping("/getDictionary")     public String getDictionary(Dictionary dictionary){     }     @RequestMapping("/getInvoiceCheckConfig")     public String getInvoiceCheckConfig(){     }          @RequestMapping("/payeeList")     public String payeeList(){     }      }

    为啥不能同时 共存呢?只能看源码呢? 懒得看的,没意思。 正常写代码,就用public,搞啥鬼娃子private,就不会出现这么多没必要的bug。

    看代码结果,推测:优先public方法,如果没找到,再用private方法暴露。

     

    最新回复(0)