项目启动成功后直接退出,没有报错
问题现象
问题原因
pom中的spring-boot-starter依赖有问题
问题代码
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.7.1</version>
<scope>test</scope>
</dependency>
</dependencies>
解决办法
<!-- 修改依赖为spring-boot-starter-web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.1</version>
</dependency>
错误一
问题现象
问题原因
SpringBoot的版本和Java JDK的版本不兼容
问题代码
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>3.0.5</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>3.0.5</version>
<scope>test</scope>
</dependency>
</dependencies>
解决办法
方法一:降低版本
<!--降低版本-->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.7.1</version>
<scope>test</scope>
</dependency>
</dependencies>
方法二:安装高版本的jdk
我这里选的是Oracle的jdk,按照自己喜欢选择