问题
启动SpringBoot项目后,直接退出,无报错信息。
2021-09-05 17:27:43.656 INFO 7336 --- [ main] cn.hsp.blog.BlogApplication : Starting BlogApplication using Java 16.0.1 on jerrydeMacBook-Pro.local with PID 7336 (/Users/jerry/Downloads/blog/target/classes started by jerry in /Users/jerry/Downloads/blog)
2021-09-05 17:27:43.657 INFO 7336 --- [ main] cn.hsp.blog.BlogApplication : No active profile set, falling back to default profiles: default
2021-09-05 17:27:44.058 INFO 7336 --- [ main] cn.hsp.blog.BlogApplication : Started BlogApplication in 5.692 seconds (JVM running for 5.981)
进程已结束,退出代码为 0
解决方案
在pom.xml中添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
完整pom.xml文件样例:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>cn.hsp</groupId>
<artifactId>blog</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>blog</name>
<description>博客-花生皮编程</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
关于我
厦门大学计算机专业 | 前华为工程师
分享编程技术,没啥深度,但看得懂,适合初学者。
Java | 安卓 | 前端 | 小程序 | 鸿蒙
公众号:花生皮编程