production-debug.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta name="generator" content="Asciidoctor 2.0.15">
  8. <meta name="author" content="pxzxj, pudge.zxj@gmail.com, 2021/12/02">
  9. <title>线上环境调试方法</title>
  10. <link rel="stylesheet" href="css/site.css">
  11. <link href="css/custom.css" rel="stylesheet">
  12. <script src="js/setup.js"></script><script defer src="js/site.js"></script>
  13. </head>
  14. <body class="article toc2 toc-left"><div id="banner-container" class="container" role="banner">
  15. <div id="banner" class="contained" role="banner">
  16. <div id="switch-theme">
  17. <input type="checkbox" id="switch-theme-checkbox" />
  18. <label for="switch-theme-checkbox">Dark Theme</label>
  19. </div>
  20. </div>
  21. </div>
  22. <div id="tocbar-container" class="container" role="navigation">
  23. <div id="tocbar" class="contained" role="navigation">
  24. <button id="toggle-toc"></button>
  25. </div>
  26. </div>
  27. <div id="main-container" class="container">
  28. <div id="main" class="contained">
  29. <div id="doc" class="doc">
  30. <div id="header">
  31. <h1>线上环境调试方法</h1>
  32. <div class="details">
  33. <span id="author" class="author">pxzxj</span><br>
  34. <span id="author2" class="author">pudge.zxj@gmail.com</span><br>
  35. <span id="author3" class="author">2021/12/02</span><br>
  36. </div>
  37. <div id="toc" class="toc2">
  38. <div id="toctitle">Table of Contents</div>
  39. <span id="back-to-index"><a href="index.html">Back to index</a></span><ul class="sectlevel1">
  40. <li><a href="#_背景">1. 背景</a></li>
  41. <li><a href="#_方法">2. 方法</a></li>
  42. </ul>
  43. </div>
  44. </div>
  45. <div id="content">
  46. <div class="sect1">
  47. <h2 id="_背景"><a class="anchor" href="#_背景"></a>1. 背景</h2>
  48. <div class="sectionbody">
  49. <div class="paragraph">
  50. <p>在某些业务场景中,开发的功能无法本地验证,只能在测试环境甚至生产环境验证,典型的如调用其它厂商的Rest接口或者Webservice接口,
  51. 对方服务只能在内网环境访问,此时需要将开发的程序打包部署在内网环境进行调试验证,验证失败则根据异常信息修改代码重新打包部署,
  52. 如此重复数次甚至数十次直到联调成功,这个过程浪费大量时间在打包部署上面,更好的方式是直接在线上环境修改代码并执行验证。</p>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="sect1">
  57. <h2 id="_方法"><a class="anchor" href="#_方法"></a>2. 方法</h2>
  58. <div class="sectionbody">
  59. <div class="paragraph">
  60. <p><a href="https://github.com/pxzxj/webservice-demo/tree/master/client">webservice-client</a> 仓库中包含了一个 <code>Client</code> 类用于调用webservice,
  61. 按照下面步骤操作就可以在线上环境运行 <code>Client</code></p>
  62. </div>
  63. <div class="olist arabic">
  64. <ol class="arabic">
  65. <li>
  66. <p>执行 <code>mvn dependency:copy-dependencies</code> ,将webservice-client的所有依赖jar包下载到 <code>target/dependency</code> 目录中</p>
  67. </li>
  68. <li>
  69. <p>线上环境新建一个项目目录client</p>
  70. </li>
  71. <li>
  72. <p>client目录下新建lib目录并将第一步的所有jar包上传到lib目录下</p>
  73. </li>
  74. <li>
  75. <p>client目录下新建src目录以及对应的包目录并在包下创建用于调用webservice接口的java文件</p>
  76. </li>
  77. <li>
  78. <p>编译项目 <code>javac -cp lib/* -d bin src/io/github/*.java</code></p>
  79. </li>
  80. <li>
  81. <p>运行Client类 <code>java -cp bin;lib/* io.github.Client</code></p>
  82. </li>
  83. <li>
  84. <p>如果有异常则修改 <code>Client</code> 类或者新增其它类并重复5、6步</p>
  85. </li>
  86. </ol>
  87. </div>
  88. <div class="admonitionblock note">
  89. <table>
  90. <tr>
  91. <td class="icon">
  92. <i class="fa icon-note" title="Note"></i>
  93. </td>
  94. <td class="content">
  95. 在Linux环境下第6步 <code>-cp</code> 后的多个jar包路径使用分号连接,如果所有jar包都在同一目录内,可以使用 <code>find $your-jar-lib-fold -name *.jar | xargs | sed "s/ /:/g"</code> 命令生成所有jar包的classpath结果
  96. </td>
  97. </tr>
  98. </table>
  99. </div>
  100. <div class="admonitionblock note">
  101. <table>
  102. <tr>
  103. <td class="icon">
  104. <i class="fa icon-note" title="Note"></i>
  105. </td>
  106. <td class="content">
  107. 不只是webservice,任何的java程序例如Spring Boot应用都可以使用这种方式在线上进行调试
  108. </td>
  109. </tr>
  110. </table>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <div id="footer">
  116. <div id="footer-text">
  117. Last updated 2024-03-18 05:44:42 UTC
  118. </div>
  119. </div>
  120. <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/highlight.min.js"></script>
  121. <script>
  122. if (!hljs.initHighlighting.called) {
  123. hljs.initHighlighting.called = true
  124. ;[].slice.call(document.querySelectorAll('pre.highlight > code')).forEach(function (el) { hljs.highlightBlock(el) })
  125. }
  126. </script>
  127. <script src="https://utteranc.es/client.js"
  128. repo="pxzxj/articles"
  129. issue-term="title"
  130. label="utteranc"
  131. theme="github-light"
  132. crossorigin="anonymous"
  133. async>
  134. </script>
  135. </div>
  136. </div>
  137. </div>
  138. </body>
  139. </html>