运行时java.lang.noclassdeffounderror:lorg/springframework/beans/factory/access/beanfactoryreference在spring从4升级到5之后

wz8daaqr  于 2021-07-24  发布在  Java
关注(0)|答案(2)|浏览(333)

我将java应用程序从Spring4升级到Spring5,并且在tomcat服务器上运行时出现java.lang.noclassdeffounderror:lorg/springframework/beans/factory/access/beanfactoryreference错误。接着是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

请让我知道,如果更多的信息需要从我这边。

wfsdck30

wfsdck301#

没有什么需要修复的,您必须经历从Spring4.x到5.x的升级/迁移过程。这是一个主要的升级,因此可以预期类将被删除。
正如core spring developer在此所述:
我很害怕 BeanFactoryReference co和co在5.0中完全消失了。您需要清理依赖项,以便它们都与SpringFramework5.0兼容(…)
话虽如此,您需要在这里阅读5.0的升级指南,然后再继续工作,直到5.3

cu6pst1q

cu6pst1q2#

我自己解决了。我用tomcat->clean清除了tomcat的历史记录,我做了gradle刷新,再次在tomcat服务器上运行并解决了问题。
tomcat采用了应用程序的旧版本。在以前的版本中,我有springws-core:2.x.release which 带来了spring-beans.4.x.jar,它与其他spring 5 jar不兼容。所以根本原因是jar和tomcat缓存构建不兼容。

相关问题