You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot 3.0.6 REST API构建Native Image启动失败原因排查

Spring Boot 3.0.6 Native Image启动报No available JtaPlatform candidates的原因

核心原因

Spring Boot 3.0.6升级了Hibernate依赖(从6.1.7.Final到6.1.8.Final),该Hibernate版本在Native Image静态编译场景下,对JtaPlatform候选类的检测逻辑发生了变化,导致Spring Boot自动配置默认提供的NoJtaPlatform实现未被正确纳入Native镜像中。

Native Image是静态提前编译(AOT)技术,会剔除所有未被直接引用或标记为需要保留的类。在3.0.5版本中,Spring Boot的自动配置逻辑会确保NoJtaPlatform这类默认JtaPlatform实现被强制包含在Native镜像里;但3.0.6版本搭配新的Hibernate版本后,这部分逻辑的兼容处理出现了遗漏,启动时Hibernate无法找到可用的JtaPlatform候选,从而抛出BeanCreationException。

临时解决方法

  • 显式指定JtaPlatform:在配置文件(application.properties或application.yml)中添加以下配置,强制使用无事务管理器的JtaPlatform实现:
    spring.jpa.properties.hibernate.transaction.jta.platform=org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
    
  • 强制包含类到Native镜像:在项目的native-image.properties文件中添加参数,确保该类在编译时被初始化并包含:
    --initialize-at-build-time=org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform
    

内容的提问来源于stack exchange,提问作者BullyWiiPlaza

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.23 12:47:03