将测试环境和生产环境有区别的代码用以下方法分开 public class AmbientUtils { // 防止生产出错 这样保证把问题放在本地测试环境 生产环境不会出错 public static boolean isTest() { // return false; String testIp = "192.168.xxx.xxx"; //自己的本地IP 生产环境建议直接ruturn false try { InetAddress ia = InetAddress.getLocalHost(); String localip = ia.getHostAddress(); if (testIp.equals(ia.getHostAddress())) return true; } catch (Exception e) { e.printStackTrace(); } return false; } }
测试环境代码误上了生产环境教你1招把问题留到测试环境
最新推荐文章于 2024-05-30 20:11:47 发布