Intellij IDEA必備插件,提高效率的“七種武器”

{"type":"doc","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"常言道“工欲善其事必先利其器”,作爲一個程序員,一個好的IDE可以起到事半功倍的效果。"},{"type":"link","attrs":{"href":"https://snyk.io/wp-content/uploads/jvm_2020.pdf","title":""},"content":[{"type":"text","text":"2020 JVM 生態報告"}]},{"type":"text","text":"顯示 Intellij IDEA 已經成爲Java開發者的首選。Intellij IDEA的強大不止在於其本身提供的各種功能,也依賴於其插件體系爲第三方提供了擴展能力。今天我就分享一下自己常用的插件,有了這些工具的幫助,寫bug都比別人快一步(o´ω`o)。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"1.Maven Helper"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"作爲最流行的Java應用構建工具,Maven在簡化了依賴管理的同時,其依賴傳遞機制也可能在不經意間同時引入同一個依賴的多個版本造成依賴衝突,在不借助其他工具的情況下可以使用"},{"type":"codeinline","content":[{"type":"text","text":"maven dependency:tree"}]},{"type":"text","text":"命令查看依賴關係,但當依賴比較多時,這個效率是比較低的,藉助Maven Helper插件可以更簡單的發現衝突並解決。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在插件安裝之後,打開pom.xml時在底部會多出一個 "},{"type":"text","marks":[{"type":"strong"}],"text":"Dependency Analyzer"},{"type":"text","text":"選項,如圖:"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/b9/b90e03ad80b5775ad0a05d39ba87ddfa.png","alt":null,"title":null,"style":null,"href":null,"fromPaste":true,"pastePass":true}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"勾選"},{"type":"text","marks":[{"type":"strong"}],"text":"Conflicts"},{"type":"text","text":"查看衝突,然後可以選擇跳轉到源碼或直接排除。"}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"2.CodeGlance"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Sublime Text編輯器有一個"},{"type":"codeinline","content":[{"type":"text","text":"Minimap"}]},{"type":"text","text":"功能,可以在代碼編輯區右側顯示代碼縮略圖,進行快速跳轉。Intellij IDEA可以通過安裝CodeGlance插件實現同樣的功能。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"安裝使用效果如下:"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/ef/efc43dd5e10edb4e882216c85dab81b0.gif","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"3.Free Mybatis plugin"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在使用MyBatis框架的時候,發現Mapper接口和XML文件之間跳轉十分的麻煩,經常的操作是在Mapper接口中將接口名稱複製一下,然後去查找對應的XML文件,打開後CRTL+F查找對應的xml實現,效率很低。安裝"},{"type":"codeinline","content":[{"type":"text","text":"Free Mybatis plugin"}]},{"type":"text","text":"插件可以像Java代碼一樣直接跳轉。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"效果圖:"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/d2/d234bb8ddee788c17db3cf0c26a7c345.gif","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"此外,插件還能及時發現mapper文件和xml文件的潛在的問題,比如方法名不匹配、字段不存在等,如圖:"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/76/767e4fc802824ae8ea75f7f598f68d9a.jpeg","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"4.Mybatis Log Plugin"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"使用MyBatis框架的時候,可以配置打印sql語句,但打印出來的是使用了佔位符的預編譯語句,我們通常需要手動將參數拼接上才能獲取可以實際執行的sql語句。"},{"type":"codeinline","content":[{"type":"text","text":"Mybatis Log Plugin"}]},{"type":"text","text":" 插件可以自動將預編譯語句轉換爲可執行的語句,這在查找問題的時候非常有用。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"效果圖:"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/fa/fa70c5378d17124b3cc56289b738dfeb.gif","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"5.Grep Console"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"一般應用在運行的時候會產生大量的日誌,不同級別的日誌混雜在一起不容易區分且不好查找,以往的做法是通過自定義日誌格式實現代碼高亮,如圖:"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/b7/b79a08e5a9013fe929668a793d9c8de7.jpeg","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"這種方式麻煩且對代碼有入侵,更好的方法是使用Grep Console插件爲不同pattern的日誌設置顏色。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"效果圖:"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/ed/edf4c53c25d8be2334931021bfc7f39d.jpeg","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"6.Gsonformat"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在實際開發中,經常會遇到將json格式字符串轉換爲Java Bean的情況,一般做法是新建一個類然後添加字段,費時費力不說還可能出錯,Gsonformat插件可以解析json自動填充字段,支持嵌套結構。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"效果圖:"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/e1/e1d39f284c1999a3ea30678ac8ada28f.gif","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"在使用的時候可以勾選使用"},{"type":"codeinline","content":[{"type":"text","text":"Lombok"}]},{"type":"text","text":"註解,減少代碼量。"}]}]},{"type":"heading","attrs":{"align":null,"level":4},"content":[{"type":"text","text":"7.Rainbow Brackets"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Rainbow Brackets是一個簡單但很有用的插件,它可以實現對不同層級括號使用不同的顏色高亮,增加辨識度,特別是在嵌套層級比較多或者代碼縮進不規範的時候作用更明顯。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"效果圖:"}]},{"type":"image","attrs":{"src":"https://static001.geekbang.org/infoq/ff/ffc4b0fef478a447e1cea7c62b7bbe77.jpeg","alt":null,"title":"","style":[{"key":"width","value":"100%"},{"key":"bordertype","value":"none"}],"href":"","fromPaste":false,"pastePass":false}},{"type":"heading","attrs":{"align":null,"level":3},"content":[{"type":"text","text":"總結"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"Intellij IDEA 的插件機制爲開發者提供了更多的可能,使用官方提供的 "},{"type":"text","marks":[{"type":"strong"}],"text":"Intellij Platform Plugin SDK"},{"type":"text","text":" 你也可以自己開發一個插件玩玩。如果你發現一些好用的插件,也可以通過留言分享出來。"}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"blockquote","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","text":"最新、更多漫畫請關注微信公衆號:碼農神說。轉載開白可聯繫助手,微信號:codeceo-01"}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"text","marks":[{"type":"strong"}],"text":"相關閱讀"}]},{"type":"bulletedlist","content":[{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://xie.infoq.cn/article/d49e5aa412e022cb6afc48656","title":""},"content":[{"type":"text","text":"接住嘍,送你個裝逼技能:JDK 動態代理"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://xie.infoq.cn/article/b8c67ad20a1aa039c8312e0e8","title":""},"content":[{"type":"text","text":"給“小白”漫畫 + 圖示講解 MyBatis 原理,就問香不香!"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://xie.infoq.cn/article/81029df24c99eb5911edf3bbb","title":null},"content":[{"type":"text","text":"闢謠:程序員不配談戀愛?你錯的可以!真相來了"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://xie.infoq.cn/article/41846b3fa362bbef382c6babf","title":null},"content":[{"type":"text","text":"面試官:CAP 都搞不清楚,別跟我說你懂微服務!"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://xie.infoq.cn/article/b7195f780e45dd68a827dffb1","title":null},"content":[{"type":"text","text":"看看吧!28歲退休的程序員和P8都幹了啥"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://xie.infoq.cn/article/56c1c92104e7b4e0ae67ddfca","title":null},"content":[{"type":"text","text":"千萬不能讓程序員給娃娃取名字"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://xie.infoq.cn/article/8dfe1ea299db76c33e37a4056","title":null},"content":[{"type":"text","text":"漫畫 | 啊哈,給我一碗孟婆湯"}]}]}]},{"type":"listitem","content":[{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null},"content":[{"type":"link","attrs":{"href":"https://xie.infoq.cn/article/c2c7ecc71c17ec054e9c62fd3","title":null},"content":[{"type":"text","text":"漫畫 | 人工智能之機械基"}]}]}]}]},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}},{"type":"paragraph","attrs":{"indent":0,"number":0,"align":null,"origin":null}}]}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章