1. why
今天在釋出springboot 3.2.3 程式的時候 使用了之前匯出的jre
D:\soft\jdk\jdk-21\bin\jlink.exe --module-path jmods --add-modules java.base,java.compiler,java.datatransfer,java.desktop,java.instrument,java.logging,java.management,java.management.rmi,java.naming,java.net.http,java.prefs,java.rmi,java.se,java.security.jgss,java.security.sasl,java.smartcardio,java.sql,java.sql.rowset,java.transaction.xa,java.xml,java.xml.crypto --output jre
結果程式莫名其妙的報反射錯誤,
2024-07-31 15:00:14,340 [main] ERROR org.springframework.boot.SpringApplication -[SpringApplication.java:859]- Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'welcomePageHandlerMapping' defined in class path resource ... ... Caused by: java.lang.NoSuchMethodException: org.springframework.boot.autoconfigure.web.format.WebConversionService$$SpringCGLIB$$0.<init>() at java.base/java.lang.Class.getConstructor0(Class.java:3761) at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2930) at org.springframework.aop.framework.ObjenesisCglibAopProxy.createProxyClassAndInstance(ObjenesisCglibAopProxy.java:80) ... 44 common frames omitted
找了好幾個小時也沒弄清楚少哪個模組,然後
2. 生成包含全部模組的jre
D:\soft\jdk\jdk-21\bin\jlink.exe --add-modules ALL-MODULE-PATH --output jre --strip-debug --no-man-pages --no-header-files --compress=2
生成後jre 大小不到 90M