我正在尝试将多个项目中的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>Finchley.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>
现在,当我尝试启动我的应用程序时,出现以下错误:
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/annotation/MergedAnnotations$SearchStrategy
我检查了一下,根据文档,该类应该在我当前的spring-core版本中可用:https://docs.spring.io/spring/docs/5.2.0.RELEASE/javadoc-api/org/springframework/core/annotation/MergedAnnotations.SearchStrategy.html
当声明作为Spring IO Platform一部分的工件时不带版本号时,将使用预定义的依赖关系版本,而对于spring-core,则为
org.springframework spring-core 5.0.13.RELEASE
[https://docs.spring.io/spring/docs/5.0.13.RELEASE/javadoc-api/org/springframework/core/annotation/缺少MergedAnnotations类。
用您选择的版本声明依赖项
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.2.0.RELEASE</version>
</dependency>