迁移到新的spring后无法启动服务器 启动Tomcat上下文错误

问题描述 投票:0回答:1

最近,我不得不将我的项目升级到最新的Grails、Gradle、Groovy,并且遇到了很多问题。目前,我在启动Tomcat时遇到了这个特殊的问题。

2020-06-07 17:23:22.919 ERROR --- [           main] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'authenticationProcessingFilterDeregistrationBean': Cannot resolve reference to bean 'authenticationProcessingFilter' while setting bean property 'filter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationProcessingFilter': Cannot resolve reference to bean 'authenticationManager' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager': Cannot resolve reference to bean 'daoAuthenticationProvider' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider': Cannot resolve reference to bean 'userDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService': Unsatisfied dependency expressed through method 'setTargetDatastore' parameter 0; 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.NullPointerException: Cannot invoke method call() on null object
2020-06-07 17:23:22.958 ERROR --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat

我搜索了所有可能的Spring和Grails的组合,但我找不到到底是什么东西不工作。

我的依赖关系是。

dependencies {
    // added the new way using Log4j2, yes, spring makes it easy
    compile "org.springframework.boot:spring-boot-starter-log4j2"

    // changed spring-boot-autoconfigure so that it would not
    // pull in the logback binding/implementation
    compile ('org.springframework.boot:spring-boot-autoconfigure') {
        exclude group: 'ch.qos.logback', module: 'logback-classic'
    }
    compile ('org.springframework.boot:spring-boot-starter') {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    }
    //
    compile group: 'org.springframework.security', name: 'spring-security-core', version: '5.3.2.RELEASE'
    compile group: 'org.springframework.security', name: 'spring-security-web', version: '5.3.2.RELEASE'


    // and finally, added the log4j2 binding/implementation
    compile "org.apache.logging.log4j:log4j-api:2.13.2"
    compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.2'

//    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:grails-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-plugin-i18n"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:async"
    compile "org.grails.plugins:scaffolding"
    compile "org.grails.plugins:events"
    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core:5.1.10.Final"
    compile "org.grails.plugins:gsp"
    compile 'org.grails.plugins:spring-security-core:4.0.0'
    compile 'org.grails.plugins:mail:2.0.0'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'

    implementation 'com.squareup.okhttp3:okhttp:3.9.1'
    implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.9.1'

    console "org.grails:grails-console"
    profile "org.grails.profiles:web"

    runtime "org.glassfish.web:el-impl:2.1.2-b03"
    runtime "org.apache.tomcat:tomcat-jdbc"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.14.2"
    runtime 'mysql:mysql-connector-java:5.1.29'

    testCompile "org.grails:grails-gorm-testing-support"
    testCompile "org.grails.plugins:geb"
    testCompile "org.grails:grails-web-testing-support"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}dependencies {
    // added the new way using Log4j2, yes, spring makes it easy
    compile "org.springframework.boot:spring-boot-starter-log4j2"

    // changed spring-boot-autoconfigure so that it would not
    // pull in the logback binding/implementation
    compile ('org.springframework.boot:spring-boot-autoconfigure') {
        exclude group: 'ch.qos.logback', module: 'logback-classic'
    }
    compile ('org.springframework.boot:spring-boot-starter') {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    }
    //
    compile group: 'org.springframework.security', name: 'spring-security-core', version: '5.3.2.RELEASE'
    compile group: 'org.springframework.security', name: 'spring-security-web', version: '5.3.2.RELEASE'


    // and finally, added the log4j2 binding/implementation
    compile "org.apache.logging.log4j:log4j-api:2.13.2"
    compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.2'

//    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:grails-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-plugin-i18n"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:async"
    compile "org.grails.plugins:scaffolding"
    compile "org.grails.plugins:events"
    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core:5.1.10.Final"
    compile "org.grails.plugins:gsp"
    compile 'org.grails.plugins:spring-security-core:4.0.0'
    compile 'org.grails.plugins:mail:2.0.0'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'

    implementation 'com.squareup.okhttp3:okhttp:3.9.1'
    implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.9.1'

    console "org.grails:grails-console"
    profile "org.grails.profiles:web"

    runtime "org.glassfish.web:el-impl:2.1.2-b03"
    runtime "org.apache.tomcat:tomcat-jdbc"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.14.2"
    runtime 'mysql:mysql-connector-java:5.1.29'

    testCompile "org.grails:grails-gorm-testing-support"
    testCompile "org.grails.plugins:geb"
    testCompile "org.grails:grails-web-testing-support"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}

在升级之前,一切都很好。 所有的升级都是在依赖关系中完成的,代码没有太大变化。只做了一些密码加密。

有谁看到了什么或者知道如何解决这个问题?

谢谢大家

java spring hibernate grails gorm
1个回答
0
投票

这个问题是在版本 compile "org.hibernate:hibernate-core:5.1.10.Final" - 可能是有问题的,在改成 compile "org.hibernate:hibernate-core:5.4.10.Final" 一切工作正常。

另外,一个域名类有 static mapping = { cache true } 这也是不再工作。

© www.soinside.com 2019 - 2024. All rights reserved.