今天突然想写个测试,但是添加完依赖后启动报错了,我的这个报错是因为依赖中spring-context依赖版本问题
原本写的5.1.9.RELEASE,然后启动失败,经测试,将版本直接去掉,让依赖自己匹配
建议:加依赖的时候记得尽量看版本对应关系,如果不确定就不要加版本号,或者去百度一下,如果是spring cloud则建议引入低版本spring-boot-starter-parent依赖去匹配。
解决办法:
切换spring boot或cloud版本
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
<version>2.3.2.RELEASE</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework</groupId>-->
<!-- <artifactId>spring-context</artifactId>-->
<!我的springboot版本是2.3.2.RELEASE,去掉版本号5.1.9.RELEASE后启动成功-->
<!-- <version>5.1.9.RELEASE</version>-->
<!-- </dependency>-->
</dependencies>