英文:
Spring boot 3.0.6 native image startup failing with 'entityManagerFactory': Instantiation of supplied bean failed
问题
Spring Boot 3.0.6 依赖项,
spring-boot-starter-data-jpa
spring-boot-starter-web
使用以下命令进行构建:
mvn spring-boot:build-image -Pnative
源代码:https://github.com/askyora/native-service
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1220) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1132) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:907) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293) ~[com.example.demo.NativeServiceApplication:3.0.6]
at com.example.demo.NativeServiceApplication.main(NativeServiceApplication.java:10) ~[com.example.demo.NativeServiceApplication:na]
Caused by: java.lang.IllegalStateException: No available JtaPlatform candidates amongst [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform, org.hibernate.service.jta.platform.internal.NoJtaPlatform]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.getNoJtaPlatformManager(HibernateJpaConfiguration.java:213) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.configureJtaPlatform(HibernateJpaConfiguration.java:150) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.customizeVendorProperties(HibernateJpaConfiguration.java:139) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.entityManagerFactory(JpaBaseConfiguration.java:132) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration__BeanDefinitions.lambda$getEntityManagerFactoryInstanceSupplier$3(JpaBaseConfiguration__BeanDefinitions.java:84) ~[na:na]
at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:68) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:54) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.lambda$get$2(BeanInstanceSupplier.java:204) ~[na:na]
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.invokeBeanSupplier(BeanInstanceSupplier.java:216) ~[na:na]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:204) ~[na:na]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214) ~[com.example.demo.NativeServiceApplication:6.0.8]
... 17 common frames omitted
GitHub链接:https://github.com/askyora/native-service
英文:
Spring boot 3.0.6
dependencies,
spring-boot-starter-data-jpa
spring-boot-starter-web
build with
mvn spring-boot:build-image -Pnative
source: https://github.com/askyora/native-service
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Instantiation of supplied bean failed
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1220) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1158) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:560) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1132) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:907) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:434) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:310) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1304) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1293) ~[com.example.demo.NativeServiceApplication:3.0.6]
at com.example.demo.NativeServiceApplication.main(NativeServiceApplication.java:10) ~[com.example.demo.NativeServiceApplication:na]
Caused by: java.lang.IllegalStateException: No available JtaPlatform candidates amongst [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform, org.hibernate.service.jta.platform.internal.NoJtaPlatform]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.getNoJtaPlatformManager(HibernateJpaConfiguration.java:213) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.configureJtaPlatform(HibernateJpaConfiguration.java:150) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration.customizeVendorProperties(HibernateJpaConfiguration.java:139) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.entityManagerFactory(JpaBaseConfiguration.java:132) ~[com.example.demo.NativeServiceApplication:3.0.6]
at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration__BeanDefinitions.lambda$getEntityManagerFactoryInstanceSupplier$3(JpaBaseConfiguration__BeanDefinitions.java:84) ~[na:na]
at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:68) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:54) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.lambda$get$2(BeanInstanceSupplier.java:204) ~[na:na]
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.invokeBeanSupplier(BeanInstanceSupplier.java:216) ~[na:na]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:204) ~[na:na]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:947) ~[com.example.demo.NativeServiceApplication:6.0.8]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1214) ~[com.example.demo.NativeServiceApplication:6.0.8]
... 17 common frames omitted
答案1
得分: 2
有一个已知问题涉及到 Spring Boot 3.0.6 和 Hibernate 6.2。该问题应该在即将发布的 Spring Boot 3.0.7 中修复。现在已经在 3.0.7 的快照构建中修复了此问题。
如果需要的话,你可以在构建中临时使用 hibernate.version
属性将 Hibernate 降级到 6.1。
英文:
There is a known problem with Spring Boot 3.0.6 and Hibernate 6.2. It should be fixed in Spring Boot 3.0.7, to be released soon. The fix is in snapshot builds of 3.0.7 now.
You can manually downgrade Hibernate to 6.1 using the hibernate.version
property in your build temporarily if needed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论