簡體   English   中英

移動到新的 spring 后無法啟動服務器 啟動 Tomcat 上下文時出錯

[英]Fails to start server after moving to a new spring Error starting Tomcat context

最近,我不得不將我的項目升級到最新的 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"
}

在升級之前,一切正常。 所有升級都是在依賴項中完成的,代碼沒有太大變化。 僅某些密碼加密。

有沒有人看到了什么或知道如何解決這個問題?

謝謝

問題出在版本compile "org.hibernate:hibernate-core:5.1.10.Final" - 可能有問題,在更改為compile "org.hibernate:hibernate-core:5.4.10.Final"后一切正常。

此外,一個域 class 具有static mapping = { cache true }這也不再有效。

在我的情況下,我有運行時 springframework,通過編譯更改它並且它可以工作

runtime 'org.springframework:spring-test:4.2.1.RELEASE'

改變:

compile 'org.springframework:spring-test:4.2.1.RELEASE'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM