太优秀了,这个操作。不用每次都动很小的逻辑都发布了。
( 温馨提示:尽量只在测试环境使用,记得后续仍然要commit & push)
Idea使用ArthasHotSwap实现服务器热部署
1.搜索并安装ArthasHotSwap
插件
2.修改类中逻辑 → 右键run maven - compile 编译
3.右键ArthasHotSwap → Swap This Class。这个时候你已经复制好了如何在远程服务器上修改这个类的命令行了
4.进入到服务器中粘贴刚复制的内容并运行(根目录即可,不用特意切换目录)。看到以下日志内容说明热部署成功:
5.使用Arthas反编译查看,确认文件被修改
curl -O https://arthas.aliyun.com/arthas-boot.jar
java -jar arthas-boot.jar
jad 引用路径类名(com.xxx.xxx.xxx)
在此期间可能会存在的报错:
1.sudo: command not found
解决方式:安装sudo即可(其他command not found的解决思路类似)
Linux系统分为两种(查看命令: cat /proc/version):
(1)RedHat系列:Redhat、Centos、Fedora等。执行 yum install sudo
(2)Debian系列:Debian、Ubuntu等。执行 apt-get install sudo
我的服务器是RedHat系列,因此使用yum。如果使用apt-get会报错:apt-get: command not found
2.cat: /root/arthas-hot-swap/arthas-hot-swap-result: No such file or directory
请检查刚输出的日志步骤7中是否报错:Error: telnet is not installed. Try to use java -jar arthas-boot.jar
安装telnet即可: yum install telnet 或 apt-get install telnet
3.如果你已经打开Arthas查看反编译内容但是没有关闭,此时想要执行步骤4修改类中内容会报错进程占用。把Arthas退出即可,可执行stop