最近很多小伙伴私信我要我出一个springboot搭配jdk21的教程,应粉丝要求,我去spring官网找到了springboot和jdk版本的是配图,供大家参考!之前博主写的springboot 3.0.0 搭配jdk20不知道各位小伙伴们有没有看过呢?现在jdk21出来了,springboot 3.0.0的版本已经不够用了,需要升级到springboot 3.1.x系列的版本才可以与之匹配。
4.0.0 org.springframework.boot spring-boot-starter-parent 3.1.0 UTF-8 UTF-8 UTF-8 21 21 21 21 true
如果你的项目中有使用Lombok,并且版本呢是1.18.28,可能会出现这个问题,这是因为此版本并不支持jdk21,需要升级到1.18.30。
java: java.lang.NoSuchFieldError: Class com.sun.tools.javac.tree.JCTree$JCImport does not have member field 'com.sun.tools.javac.tree.JCTree qualid'
org.projectlombok lombok 1.18.30 provided
FROM alpine:3.15 ARG version=21.0.0.34.1 # Please note that the THIRD-PARTY-LICENSE could be out of date if the base image has been updated recently. # The Corretto team will update this file but you may see a few days' delay. RUN wget -O /THIRD-PARTY-LICENSES-20200824.tar.gz https://corretto.aws/downloads/resources/licenses/alpine/THIRD-PARTY-LICENSES-20200824.tar.gz && \ echo "82f3e50e71b2aee21321b2b33de372feed5befad6ef2196ddec92311bc09becb /THIRD-PARTY-LICENSES-20200824.tar.gz" | sha256sum -c - && \ tar x -ovzf THIRD-PARTY-LICENSES-20200824.tar.gz && \ rm -rf THIRD-PARTY-LICENSES-20200824.tar.gz && \ wget -O /etc/apk/keys/amazoncorretto.rsa.pub https://apk.corretto.aws/amazoncorretto.rsa.pub && \ SHA_SUM="6cfdf08be09f32ca298e2d5bd4a359ee2b275765c09b56d514624bf831eafb91" && \ echo "${SHA_SUM} /etc/apk/keys/amazoncorretto.rsa.pub" | sha256sum -c - && \ echo "https://apk.corretto.aws" >> /etc/apk/repositories && \ apk add --no-cache amazon-corretto-21=$version-r0 && \ rm -rf /usr/lib/jvm/java-21-amazon-corretto/lib/src.zip ENV LANG C.UTF-8 ENV JAVA_HOME=/usr/lib/jvm/default-jvm ENV PATH=$PATH:/usr/lib/jvm/default-jvm/bin
docker build -t openjdk:21-jdk-alpine .