Javers在应用程序启动期间重新创建表

时间:2019-10-17 14:51:11

标签: javers

在将应用程序启动过程中失败并显示以下日志后,我们将应用程序更新为最新的Spring版本和Javers版本

   2019-10-17 19:51:37,309 30688 ERROR [main] o.s.boot.SpringApplication [SpringApplication.java:821] --- Application run failed 
    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'JPADeleteAspect': Unsatisfied dependency expressed through field 'javers'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'javers' defined in class path resource [com/common/audit/JaversSpringJpaApplicationConfig.class]: Invocation of init method failed; nested exception is org.polyjdbc.core.exception.SchemaManagerException: [DDL_ERROR] Failed to run DDL:
    CREATE TABLE jv_commit (
    commit_pk NUMBER NOT NULL,
    author VARCHAR2(200),
    commit_date TIMESTAMP,
    commit_date_instant VARCHAR2(30),
    commit_id NUMBER(22,2),
    CONSTRAINT jv_commit_pk PRIMARY KEY(commit_pk)
    ) 
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
        at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:311)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202)
        at 
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'javers' defined in class path resource [com/common/audit/JaversSpringJpaApplicationConfig.class]: Invocation of init method failed; nested exception is org.polyjdbc.core.exception.SchemaManagerException: [DDL_ERROR] Failed to run DDL:
    CREATE TABLE jv_commit (
    commit_pk NUMBER NOT NULL,
    author VARCHAR2(200),
    commit_date TIMESTAMP,
    commit_date_instant VARCHAR2(30),
    commit_id NUMBER(22,2),
    CONSTRAINT jv_commit_pk PRIMARY KEY(commit_pk)
    )

Caused by: java.sql.SQLSyntaxErrorException: ORA-00955: name is already used by an existing object

    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:193)
    at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:999)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
    at oracle.jdbc.driver.OracleStatement.executeInternal(OracleStatement.java:1890)
    at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1855)
    at oracle.jdbc.driver.OracleStatementWrapper.execute(OracleStatementWrapper.java:304)
    at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95)
    at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java)
    at org.polyjdbc.core.schema.SchemaManagerImpl.ddl(SchemaManagerImpl.java:88)
    ... 40 common frames omitted

我们最初认为问题是由于使用旧版和新版Javers的多个应用程序指向同一数据库造成的。我们仅使用最新的Javers为应用程序创建了新的数据库,并且该应用程序首次启动时没有出现任何问题,并且进一步重启失败,并出现与上述相同的错误。

使用Javers依赖项

<!-- https://mvnrepository.com/artifact/org.javers/javers-spring-jpa -->
    <dependency>
        <groupId>org.javers</groupId>
        <artifactId>javers-spring-jpa</artifactId>
        <version>5.7.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.javers/javers-spring-boot-starter-sql -->
    <dependency>
        <groupId>org.javers</groupId>
        <artifactId>javers-spring-boot-starter-sql</artifactId>
        <version>5.7.0</version>
    </dependency>

We are using spring version : 5.1.8, Oracle dialect 12c.

0 个答案:

没有答案