See the previous answer at Maven Builds Fails After Upgrade .
The maven job type is a poor choice because it requires that the job must run with the same JVM version as the agent is running. When Jenkins requires Java 17 (as it will in some future day), the maven job type will then run the jobs with Java 17. More details are in the linked article and in the links that are included in the article.