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