I tested this locally with Spring Boot 3.4.0 on Java 25 using Gradle 9.1.0 and the app failed to start with the same error you mentioned. This happens because the ASM library embedded in Spring Framework 6.2.0 (used by 3.4.0) doesn’t support Java 25 class files.
When I upgraded to Spring Boot 3.4.10 (the latest patch in the 3.4.x line), the same app ran fine on Java 25.
It looks like a patch-level issue, early 3.4.x releases didn’t fully support Java 25, but the latest patch fixed the ASM support.
What you can do is,
Upgrade to Spring Boot 3.4.10 (if you want to stay on 3.4.x).
Upgrade to Spring Boot 3.5.x, which fully supports Java 25.
Either option works fine on Java 25.