Runtime java.lang.NoClassDefFoundError: Lorg/springframework/beans/factory/access/BeanFactoryReference after Spring upgrade from 4 to 5

Runtime java.lang.NoClassDefFoundError: Lorg/springframework/beans/factory/access/BeanFactoryReference after Spring upgrade from 4 to 5

我将我的 Java 应用程序从 Spring 4 升级到 Spring 5,我收到 java.lang.NoClassDefFoundError: Lorg/springframework/beans/factory/access/BeanFactoryReference 错误,而 运行在 tomcat 服务器上。 其次是 java.lang.ClassNotFoundException:org.springframework.beans.factory.access.BeanFactoryReference

请帮我解决这个问题..

下面是我的 build.gradle 文件中的依赖项

compile 'org.springframework:spring-context-support:5.2.11.RELEASE'
compile 'org.springframework:spring-webmvc:5.2.11.RELEASE'
    
compile 'org.springframework.security:spring-security-config:5.2.8.RELEASE'
compile 'org.springframework.security:spring-security-web:5.2.8.RELEASE'
compile 'org.springframework.security:spring-security-ldap:5.2.8.RELEASE'

compile 'org.springframework.integration:spring-integration-sftp:5.2.11.RELEASE'

compile 'org.springframework.ws:spring-ws-core:3.0.9.RELEASE'
    
compile 'com.thoughtworks.xstream:xstream:1.4.14'

compile 'com.fasterxml.jackson.core:jackson-databind:2.9.10'

compile 'wsdl4j:wsdl4j:1.6.3'
compile 'commons-discovery:commons-discovery:0.2'
compile 'javax.xml:jaxrpc-api:1.1'
compile 'com.google.guava:guava:24.1.1-android'
compile('org.apache.poi:poi-ooxml:4.1.2') {
    exclude group: 'stax', module: 'stax-api'
}
compile 'javax.validation:validation-api:1.1.0.Final'
compile 'org.hibernate:hibernate-validator:5.1.3.Final'

compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'commons-fileupload:commons-fileupload:1.4'

compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.13.3'

compile 'com.lmax:disruptor:3.3.4'

compile 'org.codehaus.woodstox:woodstox-core-asl:4.4.1'

compile 'org.apache.commons:commons-csv:1.2'

providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
providedCompile 'javax.servlet.jsp.jstl:jstl-api:1.2'
providedCompile 'javax.servlet:jstl:1.2'
providedCompile 'org.glassfish.web:jstl-impl:1.2'
providedCompile 'com.microsoft.sqlserver:sqljdbc4:2.0'
providedCompile 'javax.xml.bind:jaxb-api:2.2.12'

testCompile 'org.springframework:spring-test:5.2.11.RELEASE'
    
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-all:1.9.5'
testCompile 'foo-commonj:foo-commonj:1.1.0'
testCompile 'commonj-twm:commonj-twm:1.1.0'


integrationTestCompile sourceSets.main.output
integrationTestCompile configurations.testCompile
integrationTestCompile sourceSets.test.output
integrationTestRuntime configurations.testRuntime

如果我需要更多信息,请告诉我。

没有什么可以修的,必须经历upgrading/migrating从Spring4.x到5.x的过程。这是一项重大升级,因此预计 类 将被删除。

如核心 Spring 开发人员所述 here:

I'm afraid BeanFactoryReference and co are simply gone in 5.0. You need to clean up your dependencies so that they are all Spring Framework 5.0 compatible (...)

话虽如此,您将需要阅读 5.0 的升级指南 here,然后一路升级到 5.3

我自己解决了。我通过 tomcat -> clean 清理了 tomcat 历史记录 我在 tomcat 服务器上 gradle 刷新,再次 运行 并解决了问题。

Tomcat 正在采用应用程序的旧版本。在之前的构建中,我有 spring-ws-core:2.x.RELEASE ,它带来了 spring-beans.4.x.jar 并且它与其他 spring 5 罐子不兼容。 所以根本原因是不兼容的 jars 然后 tomcat 缓存构建。