简体   繁体   English

如何使用jdeps分析胖子罐的依赖关系(spring-boot)?

[英]How to use jdeps to analysis dependency of a fat jar(spring-boot)?

The fat jar works well and I just want to use a cropped JRE. 胖子罐效果很好,我只想使用裁剪的JRE。
I tried with following: 我尝试以下:

jdeps --list-deps {my fat jar}

The result I got is: 我得到的结果是:

java.base
java.logging

If I use that to make my own JRE using jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.logging --output cropped-jre , the new JRE just can't satisify the fat jar. 如果我使用jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.logging --output cropped-jre使用它来制作自己的JRE jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.logging --output cropped-jre ,新的JRE不能满足胖子的需要。
Actually, it needs other dependencies as well as "java.sql" for example. 实际上,它还需要其他依赖项,例如“ java.sql”。
The tree view of the fat jar is: 胖子罐的树状图是:

jar tf {my fat jar}
META-INF/
META-INF/MANIFEST.MF
org/
org/springframework/
org/springframework/boot/
......
BOOT-INF/
BOOT-INF/classes/
BOOT-INF/classes/templates/
BOOT-INF/lib/{spring/netty/etc.jar}
......

How can I got all those dependency with jdeps? 如何使用jdeps获得所有这些依赖关系?

When you try to avoid this, you may try to unzip your fat jar and point it's lib to jdeps, but then you'll encounter another bug -- https://bugs.openjdk.java.net/browse/JDK-8207162 , which prevents you from using multi-version jars(such as log4j) with jdeps. 当你试图避免这种情况,您可以尝试解压缩你的脂肪罐子并将其指向的lib到jdeps,但随后你会遇到另一个错误- https://bugs.openjdk.java.net/browse/JDK-8207162 ,这样可以防止您将多版本的jar(例如log4j)与jdeps一起使用。 Finally I tried every dependency to find an answer: jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.logging,java.management,java.sql,java.transaction.xa,java.xml,java.naming,java.desktop,java.security.jgss,java.instrument,jdk.unsupported --output java-base That will generate a cropped JRE(only 40MB, based on openJDK11) which could run your spring-boot application(with Tomcat/Thymeleaf/Jedis). 最后,我尝试了每种依赖关系以找到答案:jlink --no-header-files --no-man-pages --compress = 2 --strip-debug --add-modules java.base,java.logging,java。管理,java.sql,java.transaction.xa,java.xml,java.naming,java.desktop,java.security.jgss,java.instrument,jdk.unsupported --output java-base将生成裁剪的JRE(仅40MB(基于openJDK11),可以运行您的spring-boot应用程序(使用Tomcat / Thymeleaf / Jedis)。

I guess jdeps just can't handle jars recursively. 我猜jdeps不能递归地处理jar。 Try to unpack your fat jar and run jdeps --list-deps on each of jars in <fat jar root>/lib dir. 尝试打开您的胖罐子并在<fat jar root>/lib dir中的每个罐子上运行jdeps --list-deps

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM