Currently, the Spring Boot Maven Plugin does not appear to support Maven Toolchains when executing goals like spring-boot:run.

Maven Toolchains provide a standard and flexible way to configure different JDKs for build and runtime, and they are especially helpful in CI environments or when managing multiple JDK versions locally. While the compiler and surefire plugins already support toolchains, the Spring Boot Maven Plugin seems to ignore the toolchain configuration and uses the default JDK instead.

Feature Request

Please add support for Maven Toolchains to the Spring Boot Maven Plugin, so that the configured toolchain JDK is used when:

  • Running spring-boot:run
  • Creating executable jars with spring-boot:repackage
  • Building OCI images via spring-boot:build-image
  • Any other plugin goal that relies on the JDK

Use Case / Motivation:

  • Enables consistent builds across environments, especially in CI/CD pipelines where the default JDK might not match the desired one.
  • Allows developers to use specific JDK versions for Spring Boot projects without needing to globally switch JDKs.
  • Aligns the plugin behavior with other Maven tooling that already respects toolchains.xml.

References

Comment From: wilkinsona

Spring Boot's Maven Plugin has supported toolchains since Spring Boot 2.3. The support remains for any goal that starts a new JVM (run, test-run start, process-aot, and process-test-aot). Support in other goals (such as repackage) does not really make sense as there's no separate JVM involved.

It sounds like this isn't working for you but "does not appear to support Maven Toolchains" isn't enough for us to figure out why. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.