All Projects → WangJi92 → Arthas Idea Plugin

WangJi92 / Arthas Idea Plugin

Licence: apache-2.0
arthas idea plugin 更简单的使用arthas的IDEA 插件

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Arthas Idea Plugin

Toolsetideaplugin
程序员常用的工具集Idea插件,帮助开发人员提升效率
Stars: ✭ 248 (+17.54%)
Mutual labels:  idea, idea-plugin
NutzCodeInsight
Intellij idea plugin for Nutz Web Framwork
Stars: ✭ 35 (-83.41%)
Mutual labels:  idea, idea-plugin
intelliroutes
Support for Play Routes in IntelliJ IDEA
Stars: ✭ 21 (-90.05%)
Mutual labels:  idea, idea-plugin
Awesome Idea
IntelliJ IDEA资源一网打尽
Stars: ✭ 124 (-41.23%)
Mutual labels:  idea, idea-plugin
Mvpautocodeplus
🔌An IDEA/Android Studio plug-in that automatically generates an MVP template code
Stars: ✭ 176 (-16.59%)
Mutual labels:  idea, idea-plugin
RedsoftYapiUpload
一个快速生成接口文档的IntelliJ IDEA的Yapi上传小插件,如果给你带来了方便,请给个Star 谢谢
Stars: ✭ 51 (-75.83%)
Mutual labels:  idea, idea-plugin
uuid-generator-plugin
An IntelliJ Idea plugin to generate UUID (Universally Unique Identifier), ULID (Universally Unique Lexicographically Sortable Identifier) and CUID (Collision Resistant Unique Identifier)
Stars: ✭ 30 (-85.78%)
Mutual labels:  idea, idea-plugin
intellij-treeInfotip
IDEA项目结构树中的节点添加显示自定义备注文本IDEA DirectoryNode adds custom text for display
Stars: ✭ 48 (-77.25%)
Mutual labels:  idea, idea-plugin
Yapiideauploadplugin
yapi idea 上传插件,快速生成文档
Stars: ✭ 288 (+36.49%)
Mutual labels:  idea, idea-plugin
aw-watcher-jetbrains
This extension allows the open source tracking tool ActivityWatch to keep track of the projects and coding languages you use in jetbrains IDEs.
Stars: ✭ 36 (-82.94%)
Mutual labels:  idea, idea-plugin
Idea Conventional Commit
Context and template-based completion for conventional/semantic commits.
Stars: ✭ 115 (-45.5%)
Mutual labels:  idea, idea-plugin
Intellij Mybaitslog
用于在IDEA将Mybatis的SQL日志还原为可执行的SQL,Used to restore Mybatis SQL logs to executable SQL in IDEA,
Stars: ✭ 501 (+137.44%)
Mutual labels:  idea, idea-plugin
Intellij Haxe
Haxe plugin for IntelliJ Platform based IDEs (IDEA, Android-Studio)
Stars: ✭ 188 (-10.9%)
Mutual labels:  idea, idea-plugin
Hotel Management System
宾馆管理系统。可以订房、续费、退房、订单管理、员工管理以及业务数据统计可视化展示等
Stars: ✭ 126 (-40.28%)
Mutual labels:  idea
React Native Console
🧩 an IDEA/WebStorm/Android Studio Plugin for One-Click run React Native commands in embed terminal
Stars: ✭ 159 (-24.64%)
Mutual labels:  idea-plugin
Houserentalsystem
🏠 房屋租赁系统,基于主流框架 SSM 的实战项目。
Stars: ✭ 122 (-42.18%)
Mutual labels:  idea
Open In Editor
NPM package to open a file in editor
Stars: ✭ 187 (-11.37%)
Mutual labels:  idea
Hybris Integration Intellij Idea Plugin
A plugin for integration of SAP Hybris platform with JetBrains Intellij IDEA
Stars: ✭ 142 (-32.7%)
Mutual labels:  idea
Merge Request Integration
An Intellij IDE plugin which helps you manage Merge Request and do Code Review right in your IDE.
Stars: ✭ 122 (-42.18%)
Mutual labels:  idea-plugin
Intellij Idea Tutorial
🌻 This is a tutorial of IntelliJ IDEA, you can know how to use IntelliJ IDEA better and better.
Stars: ✭ 1,947 (+822.75%)
Mutual labels:  idea

arthas idea plugin

联系方式

有问题直接加我微信wj983433479 或者 扫码添加钉钉群 32102545 沟通

帮助文档链接

给作者一个鼓励

如果你喜欢这款插件,欢迎给身边的小伙伴推荐哦哦,点赞哦

一、背景

目前Arthas 官方的工具还不够足够的简单,需要记住一些命令,特别是一些扩展性特别强的高级语法,比如ognl获取spring context 为所欲为,watch、trace 不够简单,需要构造一些命令工具的信息,因此只需要一个能够简单处理字符串信息的插件即可使用。当在处理线上问题的时候需要最快速、最便捷的命令,因此Idea arthas 插件还是有存在的意义和价值的。

二、支持的功能

支持的功能都是平时处理最常用的一些功能,一些快捷的链接,在处理紧急问题时候不需要到处查找,都是一些基本的功能,自动复制到剪切板中去,方便快捷。

image

2.1 watch

watch StringUtils uncapitalize '{params,returnObj,throwExp}' -n 5 -x 3

2.2 trace 

trace StringUtils uncapitalize -n 5

2.3 static ognl (字段或者方法)

2.3.1 右键static ognl

2.3.2 获取classload命令

必须要获取,不然会找不到classload,arthas 官方获取问题系统的classload,spring 项目应该无法获取到这个class的信息,因此首先执行一下这个命令

sc -d StringUtils

2.3.2 复制到界面,获取命令,执行即可

ognl  -x  3  '@[email protected](" ")' -c 8bed358

2.4 Invoke Bean Method

 实际上就是根据当前的spring项目中的获取静态的spring context这样可以直接根据这个context直接获取任何的Bean方法,一般在Java后端服务中都有这样的Utils类,因此这个可以看为一个常量! 可以参考:arthas idea demo 有了这个,我们可以跟进一步的进行数据简化,由于在idea这个环节中,可以获取方法参数,spring bean的名称等等,非常的方便。

package com.wangji92.arthas.plugin.demo.common;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * 提供给arthas ognl 获取context的信息
 *
 * @author 汪小哥
 * @date 30-28-2020
 */
@Component
public class ApplicationContextProvider implements ApplicationContextAware {
    private static ApplicationContext context;

    public ApplicationContext getApplicationContext() {
        return context;
    }

    @Override
    public void setApplicationContext(ApplicationContext ctx) {
        context = ctx;
    }
}

2.4.1 设置获取spring context的上下文

arthas idea plugin 配置

2.4.2 右键点击需要调用的方法

这里的策略和static ognl 一样的,本质还是ognl的调用。

ognl  -x  3  '# -c desw22

特别说明对于ognl 字段类型的处理

代码地址

public static String getDefaultString(PsiType psiType) {
        String result = " ";
        String canonicalText = psiType.getCanonicalText();

        //基本类型  boolean
        if (PsiType.BOOLEAN.equals(psiType) || canonicalText.equals("java.lang.Boolean")) {
            result = "true";
            return result;
        }

        //基本类型  String
        if (canonicalText.endsWith("java.lang.String")) {
            result = "\" \"";
            return result;
        }

        if (PsiType.LONG.equals(psiType) || "java.lang.Long".equals(canonicalText)) {
            result = "0L";
            return result;
        }

        if (PsiType.DOUBLE.equals(psiType) || "java.lang.Double".equals(canonicalText)) {
            result = "0D";
            return result;
        }

        if (PsiType.FLOAT.equals(psiType) || "java.lang.Float".equals(canonicalText)) {
            result = "0F";
            return result;
        }


        //基本类型  数字
        if (PsiType.INT.equals(psiType) || canonicalText.equals("java.lang.Integer")
                ||
                PsiType.BYTE.equals(psiType) || canonicalText.equals("java.lang.Byte")
                ||
                PsiType.SHORT.equals(psiType) || canonicalText.equals("java.lang.Short")) {
            result = "0";
            return result;
        }

        //常见的List 和Map
        if (canonicalText.startsWith("java.util.")) {
            if (canonicalText.contains("Map")) {
                result = "#{\" \":\" \"}";
                return result;
            }
            if (canonicalText.contains("List")) {
                result = "{}";
                return result;
            }
        }

        //原生的数组
        if (canonicalText.contains("[]")) {
            result = "new " + canonicalText + "{}";
            return result;
        }

        //不管他的构造函数了,太麻烦了
        result = "new " + canonicalText + "()";
        return result;

    }

2.5  install(linux)

安装脚本,可以一键的通过as.sh 进行执行

curl -sk https://arthas.aliyun.com/arthas-boot.jar  -o ~/.arthas-boot.jar  && echo "alias as.sh='java -jar ~/.arthas-boot.jar --repo-mirror aliyun --use-http 2>&1'" >> ~/.bashrc && source ~/.bashrc && echo "source ~/.bashrc" >> ~/.bash_profile && source ~/.bash_profile

image

2.6 常用特殊用法链接

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].