0

我正在尝试将 micronaut 与 oracle 和 jpa 一起使用(提出 hello world 应用程序)但休眠会话工厂实例化抛出异常

似乎其中一个序列超出了范围。但我的应用程序或实体没有加载任何实体。

io.micronaut.context.exceptions.BeanInstantiationException: Bean definition [org.hibernate.SessionFactory] could not be loaded: Error instantiating bean of type [org.hibernate.SessionFactory]: Unable to build DatabaseInformation
    at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1359)
    at io.micronaut.context.DefaultApplicationContext.initializeContext(DefaultApplicationContext.java:236)
    at io.micronaut.context.DefaultBeanContext.readAllBeanDefinitionClasses(DefaultBeanContext.java:2543)
    at io.micronaut.context.DefaultBeanContext.start(DefaultBeanContext.java:204)
    at io.micronaut.context.DefaultApplicationContext.start(DefaultApplicationContext.java:188)
    at io.micronaut.runtime.Micronaut.start(Micronaut.java:64)
    at io.micronaut.runtime.Micronaut.run(Micronaut.java:294)
    at io.micronaut.runtime.Micronaut.run(Micronaut.java:280)
    at com.mypackage.main(Service.java:7)
Caused by: io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type [org.hibernate.SessionFactory]: Unable to build DatabaseInformation
    at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1721)
    at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:2402)
    at io.micronaut.context.DefaultBeanContext.loadContextScopeBean(DefaultBeanContext.java:1983)
    at io.micronaut.context.DefaultBeanContext.initializeContext(DefaultBeanContext.java:1357)
    ... 8 common frames omitted
Caused by: org.hibernate.exception.GenericJDBCException: Unable to build DatabaseInformation
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
    at org.hibernate.tool.schema.internal.Helper.buildDatabaseInformation(Helper.java:163)
    at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:96)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:184)
    at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:320)
    at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462)
    at io.micronaut.configuration.hibernate.jpa.EntityManagerFactoryBean.hibernateSessionFactory(EntityManagerFactoryBean.java:170)
    at io.micronaut.configuration.hibernate.jpa.$EntityManagerFactoryBean$HibernateSessionFactory3Definition.build(Unknown Source)
    at io.micronaut.context.BeanDefinitionDelegate.build(BeanDefinitionDelegate.java:125)
    at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1693)
    ... 11 common frames omitted
Caused by: java.sql.SQLException: Numeric Overflow
    at oracle.jdbc.driver.NumberCommonAccessor.throwOverflow(NumberCommonAccessor.java:4136)
    at oracle.jdbc.driver.NumberCommonAccessor.getLong(NumberCommonAccessor.java:634)
    at oracle.jdbc.driver.GeneratedStatement.getLong(GeneratedStatement.java:206)
    at oracle.jdbc.driver.GeneratedScrollableResultSet.getLong(GeneratedScrollableResultSet.java:259)
    at oracle.jdbc.driver.GeneratedResultSet.getLong(GeneratedResultSet.java:558)
    at com.zaxxer.hikari.pool.HikariProxyResultSet.getLong(HikariProxyResultSet.java)
    at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.resultSetMinValue(SequenceInformationExtractorLegacyImpl.java:134)
    at org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl.extractMetadata(SequenceInformationExtractorLegacyImpl.java:60)
    at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.initializeSequences(DatabaseInformationImpl.java:65)
    at org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl.<init>(DatabaseInformationImpl.java:59)
    at org.hibernate.tool.schema.internal.Helper.buildDatabaseInformation(Helper.java:155)
    ... 20 common frames omitted

和 application.yml 是

---
micronaut:
    application:
        name: mohamedmiledijpa
        max: 50
    environments: tst
    server:
      port: 8083


---

datasources:
  default:
    url: jdbc:oracle:thin:@machinename:1521:db
    driverClassName: oracle.jdbc.driver.OracleDriver
    username: usr
    password: pwd



jpa:
  default:
    packages-to-scan: com.myservice.entity
    properties:
      hibernate:
        hbm2ddl:
          auto: update

  servicename:
      service:
        name: myservice
        realm: env1




任何帮助将不胜感激。micronaut 数据的所有示例均使用 h2 数据库。有人在使用 micronuat 数据连接到 oracle 时遇到过任何问题吗

构建.gradle

apply plugin: 'application'
apply plugin: 'java'
apply plugin: 'distribution'


mainClassName = "mainclass"


dependencies {


    annotationProcessor platform("io.micronaut:micronaut-bom:$micronautVersion")
    annotationProcessor "io.micronaut:micronaut-inject-java"
    annotationProcessor "io.micronaut:micronaut-validation"
    implementation "io.micronaut.configuration:micronaut-hibernate-jpa" // <1>
    implementation "io.micronaut.configuration:micronaut-jdbc-hikari" // <2>
    runtimeOnly 'com.oracle:ojdbc8:12.2.0.1.0'

    compile "io.micronaut:micronaut-http-server-netty"

    compile "io.micronaut.configuration:micronaut-hibernate-jpa"
}


test.classpath += configurations.developmentOnly

tasks.withType(JavaCompile){
    options.encoding = "UTF-8"
    options.compilerArgs.add('-parameters')
}

repositories {
 // organisation repositories , removed purposefully here
}



task processConfig(type: Copy) {
    from('src/main/resources') {
        include '**/*'
    }

    into ('src/dist/resources')
}

classes {
    classes.dependsOn processConfig
}

4

0 回答 0