springboot启动后不显示端口详情问题解决方案

143 阅读1分钟

springboot启动后不显示Tomcat started on port(s): 8080 (http) with context path ''

<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>

添加依赖后

image.png

spring-boot-starter-web 和 spring-boot-starter 是 Spring Boot 中常用的两个依赖,它们之间存在一些区别。

  1. spring-boot-starter-web

    • spring-boot-starter-web 是用于构建基于 Spring MVC 的 Web 应用程序的起步依赖。它包含了在开发 Web 应用时所需的大部分依赖,例如 Spring MVC、Tomcat(内嵌的 Servlet 容器)、Jackson(用于 JSON 处理)、Spring Web 等。如果您正在构建一个 Web 应用程序,可以使用该起步依赖来简化项目的配置。
  2. spring-boot-starter

    • spring-boot-starter 是一个更通用的起步依赖,它提供了 Spring Boot 应用程序所需的核心功能和自动配置。它包含了 Spring Core、自动配置、日志系统等核心模块。当您使用 spring-boot-starter 时,您需要根据实际需求选择其他具体功能的起步依赖,例如 spring-boot-starter-webspring-boot-starter-data-jpaspring-boot-starter-security 等。

因此,spring-boot-starter-web 更专注于支持 Web 应用开发所需的依赖,而 spring-boot-starter 则提供了更通用的核心功能和自动配置,适用于各种类型的应用程序。在实际项目中,根据您的需求可以选择使用其中之一或两者同时引入,以简化项目依赖管理和配置。