Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
升级spring版本后获取java.lang.NoClassDefFoundError:_Java_Spring_Pom.xml - Fatal编程技术网

升级spring版本后获取java.lang.NoClassDefFoundError:

升级spring版本后获取java.lang.NoClassDefFoundError:,java,spring,pom.xml,Java,Spring,Pom.xml,我正在尝试在我们已有的多个项目中将spring从2.1.1升级到2.2.0。 我已经在几个项目中完成了这项工作,一切都很顺利 在当前项目中,我做了相同的更改: <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version

我正在尝试在我们已有的多个项目中将spring从2.1.1升级到2.2.0。 我已经在几个项目中完成了这项工作,一切都很顺利

在当前项目中,我做了相同的更改:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.RELEASE</version>
        <relativePath/>
</parent>

<properties>
        <spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
        <spring.boot.version>2.2.0.RELEASE</spring.boot.version>
    ...
    ...

</properties>

<dependencyManagement>
        <dependencies>
            <dependency>
                <!-- Import dependency management from Spring Boot -->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring.boot.version}</version>
            </dependency>
        .....
        .....
</dependencyManagement>

<dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
        </dependency>
...
</dependencies>
我检查过,根据文档,该类应该在我当前的spring core版本中可用:

堆栈跟踪:

java.lang.NoClassDefFoundError: org/springframework/core/annotation/MergedAnnotations$SearchStrategy
        at org.springframework.boot.BeanDefinitionLoader.isComponent(BeanDefinitionLoader.java:279) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:156) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:136) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:128) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.SpringApplication.load(SpringApplication.java:691) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:392) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:140) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:197) ~[spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE]
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:104) ~[spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE]
        at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:70) ~[spring-cloud-context-2.0.0.RELEASE.jar:2.0.0.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) ~[spring-context-5.1.3.RELEASE.jar:5.1.3.RELEASE]
        at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:76) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:53) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:345) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:152) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:132) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:92) [spring-boot-2.2.0.RELEASE.jar:2.2.0.RELEASE]
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171) [spring-web-5.1.3.RELEASE.jar:5.1.3.RELEASE]
maven dependencies树,所有spring实例:

[INFO] +- org.springframework.security:spring-security-config:jar:5.2.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:5.2.0.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-core:jar:5.2.0.RELEASE:compile
[INFO] |  +- org.springframework.security:spring-security-core:jar:5.2.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:5.2.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-aop:jar:5.2.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:5.2.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:5.2.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-context:jar:5.2.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-context:jar:5.2.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-web:jar:5.2.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-web:jar:5.2.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-expression:jar:5.2.0.RELEASE:compile
[INFO] |  +- org.springframework:spring-expression:jar:5.2.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-web:jar:5.2.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-web:jar:5.2.0.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.2.0.RELEASE:provided
[INFO] +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.2.0.RELEASE:provided
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.2.0.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.2.0.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:5.2.0.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:5.2.0.RELEASE:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:2.2.0.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:2.2.0.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:2.2.0.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-orm:jar:5.2.0.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-orm:jar:5.2.0.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-tx:jar:5.2.0.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-tx:jar:5.2.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-aspects:jar:5.2.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-aspects:jar:5.2.0.RELEASE:compile
[INFO] +- org.apache.cxf:cxf-spring-boot-starter-jaxrs:jar:3.2.5:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.2.0.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:2.2.0.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:2.2.0.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.2.0.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.apache.cxf:cxf-spring-boot-autoconfigure:jar:3.2.5:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.2.0.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-actuator-autoconfigure:jar:2.2.0.RELEASE:compile
[INFO] |  |  \- org.springframework.boot:spring-boot-actuator:jar:2.2.0.RELEASE:compile
[INFO] |  |  \- org.springframework.boot:spring-boot-actuator:jar:2.2.0.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.2.0.RELEASE:test
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:2.2.0.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.2.0.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.2.0.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.2.0.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.2.0.RELEASE:test
[INFO] |  +- org.springframework:spring-test:jar:5.2.0.RELEASE:test
[INFO] |  +- org.springframework:spring-test:jar:5.2.0.RELEASE:test
[INFO] +- org.springframework.cloud:spring-cloud-config-client:jar:2.2.0.RELEASE:compile
[INFO] +- org.springframework.cloud:spring-cloud-config-client:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-commons:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-commons:jar:2.2.0.RELEASE:compile
[INFO] |  |  \- org.springframework.security:spring-security-crypto:jar:5.2.0.RELEASE:compile
[INFO] |  |  \- org.springframework.security:spring-security-crypto:jar:5.2.0.RELEASE:compile
[INFO] |  \- org.springframework.cloud:spring-cloud-context:jar:2.2.0.RELEASE:compile
[INFO] |  \- org.springframework.cloud:spring-cloud-context:jar:2.2.0.RELEASE:compile
[INFO] +- org.springframework.retry:spring-retry:jar:1.2.4.RELEASE:compile
[INFO] +- org.springframework.retry:spring-retry:jar:1.2.4.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.2.0.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-json:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-validation:jar:2.2.0.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-validation:jar:2.2.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:5.2.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:5.2.0.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:5.2.0.RELEASE:compile
[INFO] +- org.springframework:spring-core:jar:5.2.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-jcl:jar:5.2.0.RELEASE:compile
[INFO] |  \- org.springframework:spring-jcl:jar:5.2.0.RELEASE:compile
[INFO]    \- org.springframework.cloud:spring-cloud-starter-openfeign:jar:2.2.0.RELEASE:compile
[INFO]    \- org.springframework.cloud:spring-cloud-starter-openfeign:jar:2.2.0.RELEASE:compile
[INFO]       +- org.springframework.cloud:spring-cloud-starter:jar:2.2.0.RELEASE:compile
[INFO]       +- org.springframework.cloud:spring-cloud-starter:jar:2.2.0.RELEASE:compile
[INFO]       |  \- org.springframework.security:spring-security-rsa:jar:1.0.7.RELEASE:compile
[INFO]       |  \- org.springframework.security:spring-security-rsa:jar:1.0.7.RELEASE:compile
[INFO]       +- org.springframework.cloud:spring-cloud-openfeign-core:jar:2.2.0.RELEASE:compile
[INFO]       +- org.springframework.cloud:spring-cloud-openfeign-core:jar:2.2.0.RELEASE:compile
[INFO]       |  +- org.springframework.cloud:spring-cloud-netflix-ribbon:jar:2.2.0.RELEASE:compile
[INFO]       |  +- org.springframework.cloud:spring-cloud-netflix-ribbon:jar:2.2.0.RELEASE:compile
[INFO]       |  |  \- org.springframework.cloud:spring-cloud-netflix-archaius:jar:2.2.0.RELEASE:compile
[INFO]       |  |  \- org.springframework.cloud:spring-cloud-netflix-archaius:jar:2.2.0.RELEASE:compile
[INFO]       |  \- io.github.openfeign.form:feign-form-spring:jar:3.8.0:compile
参考:

当作为Spring IO平台一部分的工件在没有版本的情况下被声明时,将使用依赖项的预定义版本,而对于Spring core则是

org.springframework-springcore 5.0.13.RELEASE

缺少MergedAnnotations类

用您选择的版本声明依赖项

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>5.2.0.RELEASE</version>
    </dependency>

org.springframework
文档的第节提到了以下内容

SpringBoot的每个版本都提供了一个精心策划的依赖项列表 它所支持的。实际上,您不需要提供一个版本 对于构建配置中的任何依赖项,如Spring Boot会为您管理这些。升级Spring Boot本身时,这些 依赖项也以一致的方式升级


此外,还解释了在插入starter父项时需要进行的升级修改

请检查作为Maven依赖项的一部分添加的jar,以验证所添加的jar版本是否来自Release train Finchley的版本5.2.0,是否与Spring boot版本2.0.x兼容。尝试将其升级到Hoxton以与Spring boot版本2.2.x兼容使用Spring Cloud时,您不能简单地升级Spring boot。您还必须将SpringCloud升级到支持该SpringBoot版本的版本。旧的Spring云依赖项会拉入旧的Spring依赖项,因此您会出现异常。@M.Deinum-我试图将Spring云升级到Hoxton版本,但它没有帮助您不需要
Spring启动依赖项,正如您添加的父项已经暗示的那样。如果SpringCloud的升级不起作用,则必须有另一个依赖项拉入旧版本的Spring(或者是您自己做的)。使用
mvn dependency:tree
找出导致旧版本Spring的原因。@M.Deinum在dependency树中,我应该搜索旧版本的Spring.framework.core?我添加了依赖关系树,但没有找到任何旧版本的spring framework。很可能您的依赖关系树有问题。。。而您的IDE可能使问题更加复杂。修复注释中说明的依赖项,清除IDE缓存(如果有),退出IDE,删除“目标”目录,然后再次启动IDE并进行完整编译。
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>5.2.0.RELEASE</version>
    </dependency>