彩票网站怎么做代理,关于做网站的策划书,上海网站开发与设计,网页设计个人总结写在前面
本文看下如何查找jar冲突#xff0c;即查找哪些jar包中存在相同的class。如果是存在相同jar的不同版本#xff0c;基本一眼就能看出来#xff0c;然后结合maven的依赖关系将其剔除掉即可#xff0c;但是当你遇到了有人手动拷贝某些class到jar包中导致冲突的情况时…写在前面
本文看下如何查找jar冲突即查找哪些jar包中存在相同的class。如果是存在相同jar的不同版本基本一眼就能看出来然后结合maven的依赖关系将其剔除掉即可但是当你遇到了有人手动拷贝某些class到jar包中导致冲突的情况时就欲哭无泪了而我就曾掉入此灰常痛苦。所以本文就给出一段这样的程序方便检测。
1代码
package com.dahuyou.asr.demo;import com.sun.org.apache.xpath.internal.objects.XString;import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;public class scan_class {public static void main(String[] args) {String jarDirectoryPathd:\\test\\lib;File directory new File(jarDirectoryPath);File[] files directory.listFiles(((dir, name) - name.endsWith(.jar)));HashMapString, String hashMap new HashMap();for (File jarFile : files){try {System.out.println(jarFile.getName());JarFile jar new JarFile(jarFile);EnumerationJarEntry entries jar.entries();while (entries.hasMoreElements()) {JarEntry jarEntry entries.nextElement();String name jarEntry.getName();if (name.endsWith(.class)) {String classNamename.replace(/,.);if(hashMap.containsKey(className)){System.out.println(冲突的类className);System.out.println(存在于hashMap.get(className)和jarFile.getName());}else {hashMap.put(className,jarFile.getName());
// System.out.println(写入className jarFile.getName());}}}} catch (IOException e) {System.err.println(无法读取 JAR 文件: jarFile.getName());e.printStackTrace();}}}}测试jar,运行 另程序readme
功能
检测某一路径下所有jar包的冲突类。使用
此处换成文件路径即可
String jarDirectoryPathE:\\BaiduSyncdisk\\ZGM\\work\\bigdata_note\\软件安装\\seatunnel-2.3.3\\backend\\apache-seatunnel-2.3.3\\lib;小程序大作用 写在后面
有时候你想到了方案却觉得麻烦而不去做反而会导致更大的麻烦所以想到了就去做工作如此生活也亦应如此
参考文章列表