develop-troubleshooting.html 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. <title>Java开发问题排查方法与技巧</title>
  9. <link rel="stylesheet" href="css/site.css">
  10. <link href="css/custom.css" rel="stylesheet">
  11. <script src="js/setup.js"></script><script defer src="js/site.js"></script>
  12. </head>
  13. <body class="article toc2 toc-left"><div id="banner-container" class="container" role="banner">
  14. <div id="banner" class="contained" role="banner">
  15. <div id="switch-theme">
  16. <input type="checkbox" id="switch-theme-checkbox" />
  17. <label for="switch-theme-checkbox">Dark Theme</label>
  18. </div>
  19. </div>
  20. </div>
  21. <div id="tocbar-container" class="container" role="navigation">
  22. <div id="tocbar" class="contained" role="navigation">
  23. <button id="toggle-toc"></button>
  24. </div>
  25. </div>
  26. <div id="main-container" class="container">
  27. <div id="main" class="contained">
  28. <div id="doc" class="doc">
  29. <div id="header">
  30. <h1>Java开发问题排查方法与技巧</h1>
  31. <div id="toc" class="toc2">
  32. <div id="toctitle">Table of Contents</div>
  33. <span id="back-to-index"><a href="index.html">Back to index</a></span><ul class="sectlevel1">
  34. <li><a href="#_通用方法">1. 通用方法</a>
  35. <ul class="sectlevel2">
  36. <li><a href="#_日志">1.1. 日志</a></li>
  37. <li><a href="#_搜索">1.2. 搜索</a></li>
  38. <li><a href="#_重现">1.3. 重现</a></li>
  39. <li><a href="#_缩小范围">1.4. 缩小范围</a></li>
  40. <li><a href="#_替换">1.5. 替换</a></li>
  41. <li><a href="#_debug_remote_debug">1.6. Debug &amp; Remote Debug</a>
  42. <ul class="sectlevel3">
  43. <li><a href="#_tomcat远程调试">1.6.1. tomcat远程调试</a></li>
  44. <li><a href="#_spring_boot远程调试">1.6.2. spring boot远程调试</a></li>
  45. </ul>
  46. </li>
  47. </ul>
  48. </li>
  49. <li><a href="#_问题分类">2. 问题分类</a>
  50. <ul class="sectlevel2">
  51. <li><a href="#_系统资源">2.1. 系统资源</a>
  52. <ul class="sectlevel3">
  53. <li><a href="#_cpu占用高">2.1.1. CPU占用高</a></li>
  54. <li><a href="#_内存溢出">2.1.2. 内存溢出</a></li>
  55. </ul>
  56. </li>
  57. <li><a href="#_接口">2.2. 接口</a></li>
  58. <li><a href="#_采集">2.3. 采集</a></li>
  59. <li><a href="#_springmvc">2.4. SpringMVC</a></li>
  60. <li><a href="#_spring_boot">2.5. Spring Boot</a></li>
  61. <li><a href="#_spring_security">2.6. Spring Security</a></li>
  62. <li><a href="#_spring_data_jpa">2.7. Spring Data JPA</a></li>
  63. <li><a href="#_maven">2.8. Maven</a>
  64. <ul class="sectlevel3">
  65. <li><a href="#_依赖冲突">2.8.1. 依赖冲突</a></li>
  66. <li><a href="#_传递依赖失败">2.8.2. 传递依赖失败</a></li>
  67. </ul>
  68. </li>
  69. <li><a href="#_tomcat">2.9. Tomcat</a></li>
  70. <li><a href="#_mysql">2.10. MySQL</a></li>
  71. <li><a href="#_elasticsearch">2.11. Elasticsearch</a></li>
  72. <li><a href="#_kafka">2.12. Kafka</a></li>
  73. <li><a href="#_其它">2.13. 其它</a></li>
  74. </ul>
  75. </li>
  76. <li><a href="#_总结">3. 总结</a></li>
  77. <li><a href="#_appendices">Appendices</a></li>
  78. </ul>
  79. </div>
  80. </div>
  81. <div id="content">
  82. <div class="sect1">
  83. <h2 id="_通用方法"><a class="anchor" href="#_通用方法"></a>1. 通用方法</h2>
  84. <div class="sectionbody">
  85. <div class="sect2">
  86. <h3 id="_日志"><a class="anchor" href="#_日志"></a>1.1. 日志</h3>
  87. <div class="paragraph">
  88. <p>不论是开发或者使用其它组件,一定要知道它的日志保存在哪</p>
  89. </div>
  90. <div class="paragraph">
  91. <p>配置文件配置日志位置</p>
  92. </div>
  93. <div class="paragraph">
  94. <p>systemctl</p>
  95. </div>
  96. </div>
  97. <div class="sect2">
  98. <h3 id="_搜索"><a class="anchor" href="#_搜索"></a>1.2. 搜索</h3>
  99. <div class="paragraph">
  100. <p>关键字选择</p>
  101. </div>
  102. <div class="paragraph">
  103. <p>Google &gt;&gt; Bing &gt;&gt; baidu</p>
  104. </div>
  105. <div class="paragraph">
  106. <p>官方文档、项目Issue、javadoc</p>
  107. </div>
  108. <div class="paragraph">
  109. <p>例如搜索发现项目加入spring security后CPU利用率升高</p>
  110. </div>
  111. </div>
  112. <div class="sect2">
  113. <h3 id="_重现"><a class="anchor" href="#_重现"></a>1.3. 重现</h3>
  114. <div class="paragraph">
  115. <p>本地环境重现</p>
  116. </div>
  117. <div class="paragraph">
  118. <p>快速重现,甚至为了重现问题单独开发一个程序</p>
  119. </div>
  120. <div class="paragraph">
  121. <p>重现一般也是和下一节的缩小范围一起反复尝试</p>
  122. </div>
  123. </div>
  124. <div class="sect2">
  125. <h3 id="_缩小范围"><a class="anchor" href="#_缩小范围"></a>1.4. 缩小范围</h3>
  126. <div class="paragraph">
  127. <p>删除不相关代码</p>
  128. </div>
  129. <div class="paragraph">
  130. <p>新建测试项目
  131. 单独开发一个程序还可以避免受其它功能影响,例如axis2和cxf会相互影响</p>
  132. </div>
  133. </div>
  134. <div class="sect2">
  135. <h3 id="_替换"><a class="anchor" href="#_替换"></a>1.5. 替换</h3>
  136. <div class="paragraph">
  137. <p>有时候实现同一目的的方法有很多种,例如nginx、haproxy、端口映射都能实现反向代理,与其花大量时间解决一个方案存在的问题不如直接选择另一个方案</p>
  138. </div>
  139. </div>
  140. <div class="sect2">
  141. <h3 id="_debug_remote_debug"><a class="anchor" href="#_debug_remote_debug"></a>1.6. Debug &amp; Remote Debug</h3>
  142. <div class="sect3">
  143. <h4 id="_tomcat远程调试"><a class="anchor" href="#_tomcat远程调试"></a>1.6.1. tomcat远程调试</h4>
  144. </div>
  145. <div class="sect3">
  146. <h4 id="_spring_boot远程调试"><a class="anchor" href="#_spring_boot远程调试"></a>1.6.2. spring boot远程调试</h4>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. <div class="sect1">
  152. <h2 id="_问题分类"><a class="anchor" href="#_问题分类"></a>2. 问题分类</h2>
  153. <div class="sectionbody">
  154. <div class="sect2">
  155. <h3 id="_系统资源"><a class="anchor" href="#_系统资源"></a>2.1. 系统资源</h3>
  156. <div class="sect3">
  157. <h4 id="_cpu占用高"><a class="anchor" href="#_cpu占用高"></a>2.1.1. CPU占用高</h4>
  158. </div>
  159. <div class="sect3">
  160. <h4 id="_内存溢出"><a class="anchor" href="#_内存溢出"></a>2.1.2. 内存溢出</h4>
  161. <div class="paragraph">
  162. <p>内存溢出有多种报错形式
  163. jstat
  164. HeapDumpOnOutOfMemory
  165. MAT</p>
  166. </div>
  167. </div>
  168. </div>
  169. <div class="sect2">
  170. <h3 id="_接口"><a class="anchor" href="#_接口"></a>2.2. 接口</h3>
  171. <div class="paragraph">
  172. <p>curl</p>
  173. </div>
  174. <div class="paragraph">
  175. <p>webservice(优先选择生成客户端代码)</p>
  176. </div>
  177. <div class="paragraph">
  178. <p>浏览器控制台copy as curl</p>
  179. </div>
  180. <div class="paragraph">
  181. <p>部署到服务器后接口访问不到(防火墙问题)</p>
  182. </div>
  183. <div class="paragraph">
  184. <p>接口调用卡死(jstack查看线程栈信息,查看gc确认是否存在内存溢出问题)</p>
  185. </div>
  186. </div>
  187. <div class="sect2">
  188. <h3 id="_采集"><a class="anchor" href="#_采集"></a>2.3. 采集</h3>
  189. <div class="paragraph">
  190. <p>回显取不到或取不全</p>
  191. </div>
  192. <div class="paragraph">
  193. <p>回车问题</p>
  194. </div>
  195. </div>
  196. <div class="sect2">
  197. <h3 id="_springmvc"><a class="anchor" href="#_springmvc"></a>2.4. SpringMVC</h3>
  198. <div class="paragraph">
  199. <p>接口写了,访问404
  200. 项目部署上去</p>
  201. </div>
  202. </div>
  203. <div class="sect2">
  204. <h3 id="_spring_boot"><a class="anchor" href="#_spring_boot"></a>2.5. Spring Boot</h3>
  205. <div class="paragraph">
  206. <p>自动配置</p>
  207. </div>
  208. </div>
  209. <div class="sect2">
  210. <h3 id="_spring_security"><a class="anchor" href="#_spring_security"></a>2.6. Spring Security</h3>
  211. <div class="paragraph">
  212. <p>UsernamePasswordFilter</p>
  213. </div>
  214. </div>
  215. <div class="sect2">
  216. <h3 id="_spring_data_jpa"><a class="anchor" href="#_spring_data_jpa"></a>2.7. Spring Data JPA</h3>
  217. </div>
  218. <div class="sect2">
  219. <h3 id="_maven"><a class="anchor" href="#_maven"></a>2.8. Maven</h3>
  220. <div class="sect3">
  221. <h4 id="_依赖冲突"><a class="anchor" href="#_依赖冲突"></a>2.8.1. 依赖冲突</h4>
  222. </div>
  223. <div class="sect3">
  224. <h4 id="_传递依赖失败"><a class="anchor" href="#_传递依赖失败"></a>2.8.2. 传递依赖失败</h4>
  225. </div>
  226. </div>
  227. <div class="sect2">
  228. <h3 id="_tomcat"><a class="anchor" href="#_tomcat"></a>2.9. Tomcat</h3>
  229. <div class="paragraph">
  230. <p>出错了 catalina.out 没异常<br>
  231. 日志刷太快 打印不好看
  232. 日志分隔</p>
  233. </div>
  234. </div>
  235. <div class="sect2">
  236. <h3 id="_mysql"><a class="anchor" href="#_mysql"></a>2.10. MySQL</h3>
  237. </div>
  238. <div class="sect2">
  239. <h3 id="_elasticsearch"><a class="anchor" href="#_elasticsearch"></a>2.11. Elasticsearch</h3>
  240. </div>
  241. <div class="sect2">
  242. <h3 id="_kafka"><a class="anchor" href="#_kafka"></a>2.12. Kafka</h3>
  243. </div>
  244. <div class="sect2">
  245. <h3 id="_其它"><a class="anchor" href="#_其它"></a>2.13. 其它</h3>
  246. <div class="paragraph">
  247. <p>前后端责任不清晰,相互推诿</p>
  248. </div>
  249. </div>
  250. </div>
  251. </div>
  252. <div class="sect1">
  253. <h2 id="_总结"><a class="anchor" href="#_总结"></a>3. 总结</h2>
  254. <div class="sectionbody">
  255. <div class="paragraph">
  256. <p>以上都是简单问题
  257. 夯实基础知识</p>
  258. </div>
  259. </div>
  260. </div>
  261. <div class="sect1">
  262. <h2 id="_appendices"><a class="anchor" href="#_appendices"></a>Appendices</h2>
  263. <div class="sectionbody">
  264. <div class="videoblock"><div class="content">
  265. <iframe width="640" height="480" src="https://player.bilibili.com/player.html?bvid=BV1vt411g7F5&high_quality=1&page=1" border="0" frameborder="no" framespacing="0" scrolling="no" allowfullscreen="true"></iframe>
  266. </div></div>
  267. </div>
  268. </div>
  269. </div>
  270. <div id="footer">
  271. <div id="footer-text">
  272. Last updated 2024-03-18 05:44:42 UTC
  273. </div>
  274. </div>
  275. <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.3/highlight.min.js"></script>
  276. <script>
  277. if (!hljs.initHighlighting.called) {
  278. hljs.initHighlighting.called = true
  279. ;[].slice.call(document.querySelectorAll('pre.highlight > code')).forEach(function (el) { hljs.highlightBlock(el) })
  280. }
  281. </script>
  282. <script src="https://utteranc.es/client.js"
  283. repo="pxzxj/articles"
  284. issue-term="title"
  285. label="utteranc"
  286. theme="github-light"
  287. crossorigin="anonymous"
  288. async>
  289. </script>
  290. </div>
  291. </div>
  292. </div>
  293. </body>
  294. </html>