无法使用Postgres DB启动Grails 3.3.8应用程序 [英] Unable to start Grails 3.3.8 application with Postgres DB

查看:233
本文介绍了无法使用Postgres DB启动Grails 3.3.8应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始将应用程序从Grails 2.5.5迁移到在Postgres DB上运行的Grails 3.3.8,但是在IntelliJ中启动应用程序时出现错误.下面是详细信息:

I started migrating my application from Grails 2.5.5 to Grails 3.3.8 running on Postgres DB but getting errors while starting the application in IntelliJ. Below are the details:

错误:

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsatisfied dependency expressed through method 'methodValidationPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastoreServiceRegistry': Cannot resolve reference to bean 'hibernateDatastore' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.hibernate.boot.internal.MetadataBuildingContextRootImpl.<init>(Lorg/hibernate/boot/spi/MetadataBuildingOptions;Lorg/hibernate/boot/spi/ClassLoaderAccess;Lorg/hibernate/boot/spi/InFlightMetadataCollector;)V
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:467)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1181)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1075)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:225)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:703)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:528)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:84)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:393)
    at grails.boot.GrailsApp.run(GrailsApp.groovy:380)
    at grails.boot.GrailsApp$run.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:136)
    at com.mhz.tascr.Application.main(Application.groovy:8)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastoreServiceRegistry': Cannot resolve reference to bean 'hibernateDatastore' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError

build.gradle:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://repo.grails.org/grails/core" }
        maven { url "http://repo.grails.org/grails/plugins/" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.14.8"
    }
}

repositories {
    mavenLocal()
    mavenCentral()

    maven { url "https://repo.grails.org/grails/core" }
    maven { url "http://repo.grails.org/grails/plugins/" }
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core:5.3.6.Final"
    compile "org.hibernate:hibernate-ehcache:5.3.6.Final"

    runtime "postgresql:postgresql:9.0-801.jdbc4" // POSTGRES
}

application.yml:

hibernate:
    cache:
        queries: false
        use_second_level_cache: true
        use_query_cache: false
        region.factory_class: org.hibernate.cache.ehcache.EhCacheRegionFactory
dataSource:
    pooled: true
    jmxExport: true
    driverClassName: org.postgresql.Driver
    dialect: org.hibernate.dialect.PostgreSQLDialect
environments:
    development:
        dataSource:
            dbCreate: create-drop
            url: jdbc:postgresql://localhost:5432/dev_test
            username: XXXX
            password: XXXX
            logSql: false

gradle.properties:

grailsVersion=3.3.8
gormVersion=6.1.10.RELEASE
gradleWrapperVersion=3.5

我遵循了grails迁移指南,并给出了正确的依赖关系和Postgres方言.我还在外部库中看到了postgresql-9.0-801.jdbc4.jar,因此无法找出错误原因.

I have followed the grails migration guide and have given the correct dependencies and Postgres dialect. I also see the postgresql-9.0-801.jdbc4.jar in the External libraries so unable to figure out the cause of error.

谢谢

推荐答案

按照@erichelgeson的建议,我升级了jdbc驱动程序,但还必须进行其他一些更改,例如添加org.jadira.usertype:usertype.core:5.0.0.GA和更改 org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory使其完全正常工作.

As suggested by @erichelgeson, I upgraded my jdbc driver, but also had to make a few other changes such as adding the org.jadira.usertype:usertype.core:5.0.0.GA and changing the region.factory_class to org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory to get it fully working.

build.gradle:

buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://repo.grails.org/grails/core" }
        maven { url "http://repo.grails.org/grails/plugins/" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.14.8"
    }
}

repositories {
    mavenLocal()
    mavenCentral()

    maven { url "https://repo.grails.org/grails/core" }
    maven { url "http://repo.grails.org/grails/plugins/" }
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
    compile "org.hibernate:hibernate-ehcache"
    compile "org.jadira.usertype:usertype.core:5.0.0.GA"

    runtime "org.postgresql:postgresql:42.2.5" // POSTGRES
}

application.yml:

hibernate:
    cache:
        queries: false
        use_second_level_cache: true
        use_query_cache: true
        region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory

这篇关于无法使用Postgres DB启动Grails 3.3.8应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆