关于Jenkins服务器升级至Java11后兼容Java8/Java11应用及Maven适配的技术咨询
Hey there! Let's walk through your questions with practical, real-world insights from working with Jenkins setups:
1. Can Jenkins running on Java 11 support both Java 8 and Java 11 Spring Boot apps without issues?
Absolutely! The key here is separating the Java version Jenkins itself runs on from the Java version used for building your projects.
Once Jenkins is upgraded to run on Java 11, you can configure multiple JDK installations in Jenkins' global tool settings (under Manage Jenkins > Global Tool Configuration). For each build job:
- Select the corresponding JDK (Java 8 for your legacy apps, Java 11 for new ones)
- Ensure your Maven
pom.xmlsets the correctsourceandtargetversions in themaven-compiler-plugin(e.g.,<source>1.8</source><target>1.8</target>for Java 8 projects)
As long as you map each job to the right JDK, both types of apps will build and package normally.
2. Do I need to upgrade Maven from 3.5.2?
While Maven 3.5.2 has basic support for Java 11, it's not fully optimized. You'll likely run into minor compatibility warnings, and it may struggle with Java 11 features like the Module System (JPMS) if your Spring Boot apps use them.
My recommendation: Upgrade to Maven 3.6.3 or a newer LTS version. These releases have full, polished support for Java 11, fix bugs related to Java 11 compatibility, and work seamlessly with both Java 8 and 11 projects. It's a low-risk upgrade that will prevent unexpected build issues down the line.
3. Can I keep Java 8 installed alongside Java 11, validate both app types work, then remove Java 8 gradually?
This is actually the best practice for a smooth transition—no need to rush the removal of Java 8. Here's a step-by-step approach:
- Install Java 11 on your Jenkins server (you can use system packages or let Jenkins auto-install it via the global tool config)
- In Manage Jenkins > Global Tool Configuration, add the Java 11 installation while keeping your existing Java 8 entry
- If you're upgrading Maven, add the new Maven version here too
- Create test build jobs for both your Java 8 and Java 11 apps, selecting the respective JDK/Maven versions to verify they build successfully
- Check if any Jenkins plugins depend on Java 8 (most modern plugins support Java 11, but older ones might not—you can check plugin compatibility in Jenkins' plugin manager)
- Once all jobs are stable, and there are no remaining dependencies on Java 8, you can safely uninstall it from the server
内容的提问来源于stack exchange,提问作者acm

