{"id":16178849,"url":"https://github.com/wangji92/arthas-idea-plugin","last_synced_at":"2025-05-15T09:07:18.419Z","repository":{"id":43362431,"uuid":"229438042","full_name":"WangJi92/arthas-idea-plugin","owner":"WangJi92","description":"arthas idea  plugin 更简单的使用arthas的IDEA 插件,方便的构建各种arthas 命令,复制到剪切板 然后到服务器上启动arthas 执行命令。","archived":false,"fork":false,"pushed_at":"2025-03-04T05:08:25.000Z","size":17537,"stargazers_count":623,"open_issues_count":2,"forks_count":101,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-14T15:01:43.819Z","etag":null,"topics":["arthas","arthas-idea-plugin","idea","idea-plugin","java-tools"],"latest_commit_sha":null,"homepage":"https://plugins.jetbrains.com/plugin/13581-arthas-idea","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WangJi92.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-21T14:20:33.000Z","updated_at":"2025-04-10T06:15:45.000Z","dependencies_parsed_at":"2024-04-08T15:39:46.970Z","dependency_job_id":"8b6247ab-76ee-44b1-ad90-2e6f4462c2b8","html_url":"https://github.com/WangJi92/arthas-idea-plugin","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WangJi92%2Farthas-idea-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WangJi92%2Farthas-idea-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WangJi92%2Farthas-idea-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WangJi92%2Farthas-idea-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WangJi92","download_url":"https://codeload.github.com/WangJi92/arthas-idea-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254310515,"owners_count":22049469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arthas","arthas-idea-plugin","idea","idea-plugin","java-tools"],"created_at":"2024-10-10T05:24:41.185Z","updated_at":"2025-05-15T09:07:13.408Z","avatar_url":"https://github.com/WangJi92.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# arthas idea plugin \n### 联系方式\n有问题直接加我微信wj983433479 或者 扫码添加钉钉群 32102545 沟通\n### 帮助文档链接\nmore issue : [https://github.com/WangJi92/arthas-idea-plugin/issues label=documentation ](https://github.com/WangJi92/arthas-idea-plugin/issues?q=label%3Adocumentation+)\n   * [arthas idea plugin document](https://www.yuque.com/arthas-idea-plugin)\n   * [arthas + arthas idea plugin 实战视频](https://www.bilibili.com/video/BV1yz4y1f7iz/)\n   * [arthas-idea-plugin demo](https://github.com/WangJi92/arthas-plugin-demo)\n\n\n如果你喜欢这款插件，欢迎给身边的小伙伴推荐,给个github star,谢谢\n\n# 一、背景\n目前Arthas 官方的工具还不够足够的简单，需要记住一些命令，特别是一些扩展性特别强的高级语法，比如ognl获取spring context 为所欲为，watch、trace 不够简单，需要构造一些命令工具的信息，因此只需要一个能够简单处理字符串信息的插件即可使用。当在处理线上问题的时候需要最快速、最便捷的命令，因此Idea arthas 插件还是有存在的意义和价值的。\n\n\n# 二、支持的功能\n支持的功能都是平时处理最常用的一些功能，一些快捷的链接，在处理紧急问题时候不需要到处查找，都是一些基本的功能,自动复制到剪切板中去，方便快捷。\n\n![image](https://user-images.githubusercontent.com/20874972/77851010-fa211b80-7208-11ea-909c-e4a208f282f6.png)\n\n\n## 2.1 watch\n```bash\nwatch StringUtils uncapitalize '{params,returnObj,throwExp}' -n 5 -x 3\n```\n\n## 2.2 trace \n\n```bash\ntrace StringUtils uncapitalize -n 5\n```\n\n## 2.3 static ognl (字段或者方法)\n\n### 2.3.1 右键static ognl\n\n### 2.3.2 获取classload命令\n必须要获取，不然会找不到classload，arthas 官方获取问题系统的classload，spring 项目应该无法获取到这个class的信息，因此首先执行一下这个命令\n\n```bash\nsc -d StringUtils\n```\n\n### 2.3.2 复制到界面，获取命令，执行即可\n\n```bash\nognl  -x  3  '@StringUtils@uncapitalize(\" \")' -c 8bed358\n```\n\n## 2.4 Invoke Bean Method\n 实际上就是根据当前的spring项目中的获取静态的spring context这样可以直接根据这个context直接获取任何的Bean方法，一般在Java后端服务中都有这样的Utils类，因此这个可以看为一个常量! 可以参考:[arthas idea demo](https://github.com/WangJi92/arthas-plugin-demo/blob/master/src/main/java/com/wangji92/arthas/plugin/demo/common/ApplicationContextProvider.java) 有了这个，我们可以跟进一步的进行数据简化，由于在idea这个环节中，可以获取方法参数，spring bean的名称等等，非常的方便。\n\n```java\npackage com.wangji92.arthas.plugin.demo.common;\n\nimport org.springframework.context.ApplicationContext;\nimport org.springframework.context.ApplicationContextAware;\nimport org.springframework.stereotype.Component;\n\n/**\n * 提供给arthas ognl 获取context的信息\n *\n * @author 汪小哥\n * @date 30-28-2020\n */\n@Component\npublic class ApplicationContextProvider implements ApplicationContextAware {\n    private static ApplicationContext context;\n\n    public ApplicationContext getApplicationContext() {\n        return context;\n    }\n\n    @Override\n    public void setApplicationContext(ApplicationContext ctx) {\n        context = ctx;\n    }\n}\n\n```\n\n### 2.4.1 设置获取spring context的上下文\n 最新版本 推荐使用vmtool \n \n[arthas idea plugin 配置](https://www.yuque.com/arthas-idea-plugin/help/ugrc8n)\n \n### 2.4.2 右键点击需要调用的方法\n这里的策略和static ognl 一样的，本质还是ognl的调用。\n\n```bash\nognl  -x  3  '#springContext=@applicationContextProvider@context,#springContext.getBean(\"arthasInstallCommandAction\").actionPerformed(new com.intellij.openapi.actionSystem.AnActionEvent())' -c desw22\n```\n\n\n#### 特别说明对于ognl 字段类型的处理\n\n- [arthas 构建 vmtool \u0026 ognl \u0026 spring context.getBean 等命令入参支持复杂类型 JSON 转换](https://github.com/WangJi92/arthas-idea-plugin/issues/127)\n\n## 2.6 常用特殊用法链接\n\n- [special ognl](https://github.com/alibaba/arthas/issues/71)\n- [tt get spring context](https://github.com/alibaba/arthas/issues/482)\n- [get error filter](https://github.com/alibaba/arthas/issues/429)\n- [dubbo 遇上arthas](http://hengyunabc.github.io/dubbo-meet-arthas/)\n- [Arthas实践--jad/mc/redefine线上热更新一条龙](http://hengyunabc.github.io/arthas-online-hotswap/)\n- [ognl 使用姿势](https://blog.csdn.net/u010634066/article/details/101013479)\n\n\n\n## Development Guide\n[CONTRIBUTING](CONTRIBUTING.md)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangji92%2Farthas-idea-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwangji92%2Farthas-idea-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangji92%2Farthas-idea-plugin/lists"}