gpt4 book ai didi

java - spring boot 错误 - 由 : java. lang.IllegalStateException 引起:无法配置 JTA 平台

转载 作者:行者123 更新时间:2023-11-30 06:55:56 25 4
gpt4 key购买 nike

**I am using Java 6/Spring Framework 4.1.4/Spring Boot v1.2.1.RELEASE and Hibernate 3.5. 

由于我是Java6,所以我使用嵌入式Tomcat 7.0.59 为什么要尝试 JTA(或者我如何抑制 ComponentScan)? 这个错误是什么意思,如何解决?
我试图使用单独的注释而不是 SpringBootApplication 并且有相同的错误。 我正在尝试使用 Spring 引导创建服务,然后使用导入资源加载 HB 连接等。**

我的应用程序.properties:

server.port=2003
debug=true
spring.datasource.url=jdbc:oracle:thin:@***
spring.datasource.username=***
spring.datasource.password=***
spring.datasource.driverClassName=oracle.jdbc.driver.OracleDriver
spring.jpa.hibernate.dialect=org.hibernate.dialect.Oracle10gDialect**

我的 Gradle 片段是:

compile "org.springframework.security:spring-security-web:${springSecurityVersion}"
compile "org.springframework.security:spring-security-config:${springSecurityVersion}"
compile "org.springframework:spring-context:${springVersion}"
compile "org.springframework:spring-web:${springVersion}"
compile "org.springframework:spring-webmvc:${springVersion}"
compile "org.springframework:spring-jms:${springVersion}"
compile "org.springframework:spring-orm:${springVersion}"
compile "org.springframework:spring-jdbc:${springVersion}"
compile "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
compile "org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}"

代码:

package com.mine.apps.force;
import com.mine.common.ErrorLog;
@Controller
@EnableAutoConfiguration
@ComponentScan("com.mine")
//@ImportResource("classpath:webserver/forceAppContext.xml")
@RequestMapping(value="/force")
public class forceMicroService
{
private static ErrorLog logger = new ErrorLog("forceMicroService");

public forceMicroService()
{
}


@RequestMapping(value="/retry/{Id}", method=RequestMethod.POST)
@ResponseBody
String sendToforce(@PathVariable("Id") String Id)
{
String func = "sendToforce";

logger.Info(func, "Entering");
return Id;
}

public static void main(String[] args)
{
SpringApplication.run(forceMicroService.class, args);
}
}

堆栈跟踪是

10:06:11,443 WARN  [embedded.AnnotationConfigEmbeddedWebApplicationContext]: Exception

encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Factory method 'entityManagerFactory' threw exception; nested exception is java.lang.IllegalStateException: Could not configure JTA platform at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1111) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1006) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:956) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:747) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691) at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) at org.springframework.boot.SpringApplication.run(SpringApplication.java:961) at org.springframework.boot.SpringApplication.run(SpringApplication.java:950) at com.vzw.etm.apps.enforce.EnforceMicroService.main(EnforceMicroService.java:47) Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean]: Factory method 'entityManagerFactory' threw exception; nested exception is java.lang.IllegalStateException: Could not configure JTA platform at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ... 17 more Caused by: java.lang.IllegalStateException: Could not configure JTA platform at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.getNoJtaPlatformManager(HibernateJpaAutoConfiguration.java:151) at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.configureJtaPlatform(HibernateJpaAutoConfiguration.java:129) at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.customizeVendorProperties(HibernateJpaAutoConfiguration.java:99) at org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.entityManagerFactory(JpaBaseConfiguration.java:111) at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$6ecd1b06.CGLIB$entityManagerFactory$6() at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$6ecd1b06$$FastClassBySpringCGLIB$$797c76e5.invoke() at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309) at org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration$$EnhancerBySpringCGLIB$$6ecd1b06.entityManagerFactory() at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ... 18 more 10:06:11,465 INFO [concurrent.ThreadPoolTaskExecutor]: Shutting down ExecutorService 'metricsExecutor' Jan 12, 2016 10:06:11 AM org.apache.catalina.core.StandardService stopInternal INFO: Stopping service Tomcat

最佳答案

Spring Boot 不支持 Hibernate 3.5。
最低要求版本是 Hibernate 4.2。

您可以通过完全禁用 Hibernate 的自动配置来解决这个问题:

@EnableAutoConfiguration(exclude = {HibernateJpaAutoConfiguration.class})

如果您确实将服务部署为带有嵌入式 Tomcat 的可执行 JAR,则没有理由使用这么旧的 Hibernate 版本,因此您应该使用 Spring Boot 定义的版本。

关于java - spring boot 错误 - 由 : java. lang.IllegalStateException 引起:无法配置 JTA 平台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34748260/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com