Spring启动JTA错误

Spring启动JTA错误,spring,hibernate,jpa,spring-boot,atomikos,Spring,Hibernate,Jpa,Spring Boot,Atomikos,我正在尝试将JTA添加到我的项目中。我在Gradle文件中添加了以下内容,现在我的应用程序无法启动。以前运行得很好 compile("org.springframework.boot:spring-boot-starter-jta-atomikos") 我得到以下错误 Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name

我正在尝试将JTA添加到我的项目中。我在Gradle文件中添加了以下内容,现在我的应用程序无法启动。以前运行得很好

compile("org.springframework.boot:spring-boot-starter-jta-atomikos")
我得到以下错误

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    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:686)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
    at com.everesttech.timesheet.config.ServletInitializer.main(ServletInitializer.java:22)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1239)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:855)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:845)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:398)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:844)
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
    ... 20 more
Caused by: org.hibernate.AnnotationException: No identifier specified for entity: com.everesttech.timesheet.model.Resource
    at org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:277)
    at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:224)
    at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:775)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:3845)
    at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3799)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1412)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:852)
    ... 28 more
这是我的持久性配置文件

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.orm.jpa.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.beans.PropertyVetoException;

@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = "com.everesttech.timesheet.repository")
@EntityScan(basePackages = "com.everesttech.timesheet.model")
public class PersistenceConfig {

   @Autowired
   Environment environment;

    @Bean(name = "datasource")
    public ComboPooledDataSource dataSource() throws PropertyVetoException {
        ComboPooledDataSource dataSource = new ComboPooledDataSource();
        dataSource.setDriverClass(environment.getRequiredProperty("c3p0.driver"));
        dataSource.setJdbcUrl(environment.getRequiredProperty("c3p0.url"));
        dataSource.setUser(environment.getRequiredProperty("c3p0.user"));
        dataSource.setPassword(environment.getRequiredProperty("c3p0.password"));
        dataSource.setInitialPoolSize(environment.getRequiredProperty("c3p0.initialPoolSize", Integer.class));
        dataSource.setMaxPoolSize(environment.getRequiredProperty("c3p0.maxPoolSize", Integer.class));
        dataSource.setMinPoolSize(environment.getRequiredProperty("c3p0.minPoolSize", Integer.class));
        dataSource.setAcquireIncrement(environment.getRequiredProperty("c3p0.acquireIncrement", Integer.class));
        dataSource.setMaxStatements(environment.getRequiredProperty("c3p0.maxStatements", Integer.class));
        dataSource.setMaxIdleTime(environment.getRequiredProperty("c3p0.maxIdleTime", Integer.class));
        return dataSource;
    }
}
myapplication.yml文件

application:
  debugMode: true
c3p0:
  driver: com.mysql.jdbc.Driver
  url: jdbc:mysql://127.0.0.1:3306/timesheet?autoReconnect=true
  user: user1
  password: p@ssw0rd1
  minPoolSize: 5
  maxPoolSize: 50
  acquireIncrement: 5
  maxStatements: 100
  initialPoolSize: 10
  maxIdleTime: 600
spring.thymeleaf:
  check-template-location: true
  prefix: classpath:/views/
  suffix: .html
  mode: HTML5
  encoding: UTF-8
  content-type: text/html
  cache: false
spring.port: 8080
spring.session-timeout: 10080
spring.mvc:
  locale: en_US
  date-format: mm/DD/yyyy
spring.messages:
  basename: i18n/messages
  cache-seconds: -1
  encoding: UTF-8
security:
  enable-csrf: true
  sessions: stateless
spring.jpa:
  show-sql: true
  database-platform: MYSQL
  database: MYSQL
  hibernate.ddl-auto: create-drop
  properties:
    hibernate.hbm2ddl.auto: create-drop
    hibernate.dialect: org.hibernate.dialect.MySQL5InnoDBDialect
    hibernate.show_sql: true
    hibernate.format_sql: true
    hibernate.connection.charSet: UTF-8
    hibernate.cache.use_second_level_cache: true
    hibernate.cache.use_query_cache: true
    hibernate.cache.use_structured_entries: true
    hibernate.generate_statistics: true
    hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.EhCacheRegionFactory
spring.data.jpa.repositories.enabled: true
spring.mail:
  host: smtp.google.com
  port: 465
  username:
  password:
  default-encoding: UTF-8
aysnc.executor:
  poolSize: 5
  maxPoolSize: 10
  queueCapacity: 100

日志文件中的错误非常清楚:
没有为实体com.everestech.timesheet.model.Resource指定标识符。因此,将
@Id
注释添加到要用作实体标识符的字段中。

日志文件中的错误非常清楚:
没有为实体指定标识符:com.everestech.timesheet.model.Resource
。因此,将
@Id
注释添加到要用作实体标识符的字段中。

日志文件中的错误非常清楚:
没有为实体指定标识符:com.everestech.timesheet.model.Resource
。因此,将
@Id
注释添加到要用作实体标识符的字段中。

日志文件中的错误非常清楚:
没有为实体指定标识符:com.everestech.timesheet.model.Resource
。因此,请将
@Id
注释添加到要用作实体标识符的字段中。

请将com.everestech.timesheet.model.Resource类添加到问题中。请将com.everestech.timesheet.model.Resource类添加到问题中。请添加com.everestech.timesheet.model.Resource类请将com.everesttech.timesheet.model.Resource类添加到问题中。