背景简介
使用 maven 指令导出当前项目所有依赖 jar 包。
环境信息
- Maven 3.8.7
- Ubuntu 24.04 LTS
详细步骤
第一步: 导出 Jar 包
- 进入项目根目录并执行指令
$ mvn dependency:copy-dependencies -DoutputDirectory=target/lib
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< top.persys.ai:chatglm-api-java >-------------------
[INFO] Building chatglm-api-java 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:copy-dependencies (default-cli) @ chatglm-api-java ---
[INFO] jackson-core-2.11.3.jar already exists in destination.
[INFO] rxjava-3.1.8.jar already exists in destination.
[INFO] okio-1.17.2.jar already exists in destination.
[INFO] jackson-annotations-2.11.3.jar already exists in destination.
[INFO] retrofit-2.9.0.jar already exists in destination.
[INFO] oapi-java-sdk-release-V4-2.3.1.jar already exists in destination.
[INFO] java-jwt-4.2.2.jar already exists in destination.
[INFO] slf4j-api-2.0.11.jar already exists in destination.
[INFO] lombok-1.18.32.jar already exists in destination.
[INFO] adapter-rxjava2-2.9.0.jar already exists in destination.
[INFO] logging-interceptor-3.14.9.jar already exists in destination.
[INFO] jackson-databind-2.11.3.jar already exists in destination.
[INFO] reactive-streams-1.0.4.jar already exists in destination.
[INFO] converter-jackson-2.9.0.jar already exists in destination.
[INFO] rxjava-2.0.0.jar already exists in destination.
[INFO] okhttp-sse-3.14.9.jar already exists in destination.
[INFO] okhttp-3.14.9.jar already exists in destination.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.037 s
[INFO] Finished at: 2025-03-25T11:25:51+08:00
[INFO] ------------------------------------------------------------------------
- 查看导出结果
$ cd target/lib
$ ls -alh
总计 9.4M
drwxrwxr-x 2 myserver myserver 4.0K 3月 25 11:25 .
drwxrwxr-x 7 myserver myserver 4.0K 3月 25 11:25 ..
-rw-rw-r-- 1 myserver myserver 15K 3月 25 11:25 adapter-rxjava2-2.9.0.jar
-rw-rw-r-- 1 myserver myserver 4.0K 3月 25 11:25 converter-jackson-2.9.0.jar
-rw-rw-r-- 1 myserver myserver 67K 3月 25 11:25 jackson-annotations-2.11.3.jar
-rw-rw-r-- 1 myserver myserver 344K 3月 25 11:25 jackson-core-2.11.3.jar
-rw-rw-r-- 1 myserver myserver 1.4M 3月 25 11:25 jackson-databind-2.11.3.jar
-rw-rw-r-- 1 myserver myserver 63K 3月 25 11:25 java-jwt-4.2.2.jar
-rw-rw-r-- 1 myserver myserver 12K 3月 25 11:25 logging-interceptor-3.14.9.jar
-rw-rw-r-- 1 myserver myserver 2.0M 3月 25 11:25 lombok-1.18.32.jar
-rw-rw-r-- 1 myserver myserver 453K 3月 25 11:25 oapi-java-sdk-release-V4-2.3.1.jar
-rw-rw-r-- 1 myserver myserver 421K 3月 25 11:25 okhttp-3.14.9.jar
-rw-rw-r-- 1 myserver myserver 11K 3月 25 11:25 okhttp-sse-3.14.9.jar
-rw-rw-r-- 1 myserver myserver 90K 3月 25 11:25 okio-1.17.2.jar
-rw-rw-r-- 1 myserver myserver 12K 3月 25 11:25 reactive-streams-1.0.4.jar
-rw-rw-r-- 1 myserver myserver 123K 3月 25 11:25 retrofit-2.9.0.jar
-rw-rw-r-- 1 myserver myserver 1.9M 3月 25 11:25 rxjava-2.0.0.jar
-rw-rw-r-- 1 myserver myserver 2.6M 3月 25 11:25 rxjava-3.1.8.jar
-rw-rw-r-- 1 myserver myserver 67K 3月 25 11:25 slf4j-api-2.0.11.jar
以上便是本文的全部内容,感谢您的阅读,如遇到任何问题,欢迎在评论区留言讨论。