[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
众所周知,引入 Jar包里面的文件是改不了的,解压出来的也是 class文件。
现有需求,需要改里面的东西契合自己的项目,那怎么办?
不用担心,接下来我们就用个法子,修改里面的代码。
<>一、新建一个项目,重新引入Jar包并添加
注:最好不要在原项目中操作 Jar包,会出现一些奇怪的问题,比如我就遇到了 “Program type already present:
XXX”,这让我一度怀疑这法子不可行。
我们重新新建一个项目,重新引入Jar包并添加,也花不了多少时间
1、引入Jar包(就是直接复制 Jar包到 libs目录下,没有libs目录,自行新建就行了)
2、右键 Jar包,选择 Add As Library…
<>二、新建需要修改的包和类
说明:弄完之后就会看到里面的内容了,然后看你需要改哪里,比如我这里改 CH34xUARTDriver类,添加一个方法并打印日志;
操作:新建一个同等路径和类,复制原来的内容,然后修改内容
<>三、编译,找到对应class文件
1、编译:
2、查看class文件:build —> intermediates —> javac —> debug
<>四、替换 Jar包中的 class文件
1、解压 Jar包(先修改后缀名为可压缩的后缀,比如,zip、rar)
2、替换 class文件
3、然后重新压缩里面的文件,后缀名改为 Jar
4、最后一步就是,替换项目里面的 Jar包,over!