SpringBoot - Identify and stop the process that‘s listening on port 8080解决方案

出现Identify and stop the process that‘s listening on port 8080 or configure this application等解决方法 出现如下问题: 截图如下: 通过查看相关错误日志,发现是端口被占用了 一种是清除8080被占用的端口,另一种解决方案是换一个端口(也可不用8080端口)知道了解决方案之后就很好解决方法 具体解决方法如下关闭进程或者修改端口号两种方法通过netstat 8080,查看是否有进程在使用这个端口(但是列表中的内容比较多,不好查看比较)精确查询应该配合findstr(注意命令应和linux区分开来,这是windows版本) 完整命令如下: 杀死该进程即可: 重启服务即可成功既然端口号被占用,那就换一种思路,修改8 阅读详情

写在前面

SpringBoot很适合WEB应用的开发,该框架可以使用嵌入的TOMCAT/JETTY/UNDERTOW或者NETTY来创建self-contained HTTP server。大部分WEB应用使用spring-boot-starter-web来快速开发,也可以使用spring-boot-starter-webflux 来开发基于反应式的WEB应用。如果使用SpringBoot框架,但不是WEB应用呢?

场景描述

创建了一个基于SpringBoot框架的工程,但是在当前模块中并不需要对外提供REST服务,也不需要端口,针对这个场景,则在POM.XML中去掉了如下配置(如果这样的话,系统中没有常驻线程/监听的话,启动之后就会自动关闭),但是在该场景下启动依然会报错:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

错误描述

启动工程时报错(注意上面的场景描述):
Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port.

问题分析

由于引入了其他的模块,其他模块中将spring-boot-starter-web引入了,而当前模块中又未配置端口,所以启动时SPRINGBOOT会默认使用端口8080,而部署环境中其他项目已将8080占用,所以启动时系统报端口被占用。

当然模块本身需要端口,而端口又被占用时的处理方式与该场景不一样。

如何解决

SPRING BOOT采用不占端口的方式启动。

①. 方式一,通过API指定:
public class MyApplication {
    public static void main(String[] args) {
        new SpringApplicationBuilder(MyApplication.class).web(WebApplicationType.NONE).run(args);
        // SpringApplication.run(MyApplication.class, args);
        log.info("后端服务启动成功, 正在监听中...");
    }
}
②. 方式二,通过参数配置:
public class MyApplication {
    public static void main(String[] args) {
        // new SpringApplicationBuilder(MyApplication.class).web(WebApplicationType.NONE).run(args);
        SpringApplication.run(MyApplication.class, args);
        log.info("后端服务启动成功, 正在监听中...");
    }
}
# SPRING相关的配置
spring:
  main:
    web-application-type: none
  application:
    # 应用名称
    name: my-test-service

启动方式

// new SpringApplicationBuilder(MyApplication.class).web(WebApplicationType.NONE).run(args);
WebApplicationType的类型
类型描述备注
NONE非WEB应用程序应用程序以非WEB应用程序的方式运行,当然不会启动嵌入式的WEB容器
SERVLET基于SERVLET的WEB应用应用基于SERVLET的WEB应用程序的方式运行,同时启动嵌入式的SERVLET的WEB容器,如TOMCAT/JETTY/UNDERTOW等
REACTIVE基于反应式的WEB应用应用基于反应式的WEB应用程序的方式运行,同时启动嵌入式的反应式的WEB容器,如NETTY等
public enum WebApplicationType {
    NONE,     // 非WEB应用程序
    SERVLET,  // 基于SERVLET的WEB应用
    REACTIVE; // 基于反应式的WEB应用

    private static final String[] SERVLET_INDICATOR_CLASSES = new String[]{"javax.servlet.Servlet", "org.springframework.web.context.ConfigurableWebApplicationContext"};
    private static final String WEBMVC_INDICATOR_CLASS = "org.springframework.web.servlet.DispatcherServlet";
    private static final String WEBFLUX_INDICATOR_CLASS = "org.springframework.web.reactive.DispatcherHandler";
    private static final String JERSEY_INDICATOR_CLASS = "org.glassfish.jersey.servlet.ServletContainer";
    private static final String SERVLET_APPLICATION_CONTEXT_CLASS = "org.springframework.web.context.WebApplicationContext";
    private static final String REACTIVE_APPLICATION_CONTEXT_CLASS = "org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext";

    private WebApplicationType() {
    }

    static WebApplicationType deduceFromClasspath() {
        if (ClassUtils.isPresent("org.springframework.web.reactive.DispatcherHandler", (ClassLoader)null) && !ClassUtils.isPresent("org.springframework.web.servlet.DispatcherServlet", (ClassLoader)null) && !ClassUtils.isPresent("org.glassfish.jersey.servlet.ServletContainer", (ClassLoader)null)) {
            return REACTIVE;
        } else {
            String[] var0 = SERVLET_INDICATOR_CLASSES;
            int var1 = var0.length;

            for(int var2 = 0; var2 < var1; ++var2) {
                String className = var0[var2];
                if (!ClassUtils.isPresent(className, (ClassLoader)null)) {
                    return NONE;
                }
            }

            return SERVLET;
        }
    }

    static WebApplicationType deduceFromApplicationContext(Class<?> applicationContextClass) {
        if (isAssignable("org.springframework.web.context.WebApplicationContext", applicationContextClass)) {
            return SERVLET;
        } else {
            return isAssignable("org.springframework.boot.web.reactive.context.ReactiveWebApplicationContext", applicationContextClass) ? REACTIVE : NONE;
        }
    }

    private static boolean isAssignable(String target, Class<?> type) {
        try {
            return ClassUtils.resolveClassName(target, (ClassLoader)null).isAssignableFrom(type);
        } catch (Throwable var3) {
            return false;
        }
    }
}

在当前的工程中不引入spring-boot-starter-web可以吗?

如果无需REST服务,无需端口,则在POM.XML中去掉了如下配置即可:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

那为什么又有WEB容器(默认端口8080)的启动呢?仔细分析了一下POM.XML文件,发现引入的其他模块中添加了spring-boot-starter-web组件导致的该问题。

【AI Infra】Perfetto性能分析工具指南 Perfetto是一款开源性能分析工具,提供系统级和应用级的活动数据追踪功能。其界面分为四个区域:左侧操作区(包含Trace查看、SQL查询、预置分析等功能)、上方信息区、中间图形化展示区以及下方详细信息区。工具支持快捷键操作(w/s缩放、a/d移动、m标记等),并能高效处理大体积Trace文件。通过Timeline分析可发现性能瓶颈,如案例中update_actor耗时过高的问题,最终定位到CPU offloading导致的MemcpyH2D操作耗时过长,提出了优化方案。Perfetto相比Systrac 阅读详情

相关推荐

Jitsi Meet保姆级自建教程:5分钟搞定私有化视频会议服务器(含Docker部署避坑指南)

本文提供了一份详尽的Jitsi Meet私有化视频会议服务器自建教程。通过Docker Compose部署方案,在5分钟内即可搭建基础服务,并深入解析了SSL/TLS证书配置、TURN服务器优化等关键步骤,确保部署的安全与可扩展性,为企业构建自主可控的远程协作平台提供完整指南。

weixin_29305337的博客 620

解决80端口占用Identify and stop the process that‘s listening on port 80 or configure this application

Identify and stop the process that's listening on port 80 or configure this application

weixin_46709007的博客 1万+

【VisionMaster】图像源模块之本地图像

图像采集之图像源

zhy29563 6961

Identify and stop the process that’s listening on port 8080 or configure this application to listen

1、Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port. 如下图 字面意思(机器翻译): 识别并停止监听端口8080的进程,或将此应用程序配置为监听另一个端口。 大致意思是我们要使用的端口已被占用 方法一:关闭进程 打开cmd 输入命令 netstat 8080 的确是已被占用 继续输入cmd命令 查看占用端口的进程号

qq_26224573的博客 5万+

DBC到ARXML:AUTOSAR CAN通信栈自动化配置完整指南

在AUTOSAR架构下,DBC(CAN数据库文件)与ARXML(AUTOSAR XML)分别扮演着描述总线通信和ECU内部配置的关键角色。DBC定义了网络上的报文与信号,而ARXML则是AUTOSAR工具链交换配置数据的标准格式。在实际的ECU开发中,如何将DBC中的通信信息高效、准确地转换为ARXML,并自动生成可编译的CAN通信栈BSW配置,是许多工程师面临的痛点。借助DaVinci Configurator等工具,我们可以通过自动化导入链路消除手工映射带来的字节序错误、信号起始位偏差等高风险问题,大幅

weixin_34183910的博客 542

海康威视工业相机网络配置实战:从MVS软件操作到IP地址规划

本文详细介绍了海康威视工业相机的网络配置实战,从MVS软件操作到IP地址规划。重点讲解了IP设置的重要性、Windows系统下的网络配置步骤、避免IP冲突的技巧,以及MVS软件中的相机IP配置方法。帮助用户快速掌握工业相机的网络连接技术,确保稳定高效的图像采集。

weixin_30296405的博客 486

Identify and stop the process that's listening on port 8080 or configure this application to listen

因为我们SpringBoot的默认端口是server.port=8080,所以可能会导致端口占有的情况,下面这个问题可能是刚入门的时候经常会遇到的。 Identify and stop the process that's listening on port 8080 or configure this application to listen: 意思就是:确定并停止正在端口8080上侦听的进...

黄文孝同学的博客 8万+

使用GDScript(godot)生成仿杀戮尖塔地图

使用GDScript(godot)生成仿杀戮尖塔地图 extends Node2D export (PackedScene) var Ball var 被连接数 = {} # 每个怪物被下层怪物连接的数量 最多为2 var 连接1 = {} # 第一次连接的上层怪物位置 var 连接2 = {} # 第二次连接的上层怪物位置 var 怪物数量 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0] # 每层怪物的数量 var 总层数 =8 # 总层数 var 怪物坐标行 = {} #

weixin_45038716的博客 3011

解决Identify and stop the process that‘s listening on port 8080 端口问题

springboot运行报8080端口被占用成为

qq_57122086的博客 2718

开发板的使用

一、开发板使用学习大纲。 1、开发板组成、核心板资源,底板资源。 2、开发板连接、调试工具、串口参数配置。 3、开发板启动过程。 4、文件传输 1)使用串口传输。 上传/下载 2)使用网口传输。 上传/下载 5、临时/永久配置开发板IP地址。 6、开发板启动脚本。 二、开发板的组成。 核心板: CPU处理器: 芯片:S5P6818(三星) 内核: ARM cortex-A53 -> 八核处理器 运行内存:512MB*2=1G nandflash:4G 底板: 电源线:5V 串口...

qq_45633736的博客 2659

苏宁易购手机行情比价系统:构建一个完整的Python爬虫实战指南

在当今数字化时代,智能手机已成为人们生活中不可或缺的一部分。随着各大手机品牌每年推出多款新品,消费者面临着越来越多的选择。然而,不同电商平台、不同时间段的价格波动使得消费者很难把握最佳购买时机。苏宁易购作为国内领先的电商平台之一,拥有丰富的手机商品信息和价格数据。本文将带领读者构建一个完整的苏宁易购手机行情比价系统,帮助消费者实时掌握手机价格动态。

2201_76125261的博客 207

spring boot 遇到 Identify and stop the process that‘s listening on port 8080 or configure this applic

意思是:识别并停止在端口 8080 上监听的过程,或配置此应用程序以在其他端口上收听。在控制台输入: netstat -aon|findstr "8080"就是说端口被占用了,用不了,要不就修改端口,要不就杀掉端口。再次输入:taskkill /pid 6344 /f。spring boot 遇到。win + r 输入 cmd。

m0_64680995的博客 2841

YOLOv11改进 | 引入DEConv细节增强卷积模块:恢复细节信息,提升小目标检测精度

摘要: YOLOv11在目标检测中面临小目标检测精度不足的问题,主要由于细节信息丢失。本文提出引入DEConv(细节增强卷积)模块,通过多分支卷积和残差连接恢复高频细节,提升小目标检测性能。DEConv结合3×3卷积与空洞卷积增强边缘信息,并自适应融合特征,兼容YOLOv11的P3层(小目标关键层)且计算高效。实验表明,该改进在无人机航拍、显微镜图像等密集小目标场景中显著减少漏检,同时保持轻量化和实时性优势。代码实现可直接嵌入现有YOLO架构,仅需替换P3层卷积模块。

走向CTO的路上... 953

Action: Identify and stop the process that‘s listening on port 8080 or configure this application t

在启动springboot项目时,发现错误 Description: Web server failed to start. Port 8080 was already in use. Action: Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port. 意思是8080端口号已经被占用。 解决办法有: 一、停止另外一个在运行的项目

HNZYQ_1988的博客 1239

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Identify and stop the process that‘s listening on port 8080 or configure this application to listen

Identify and stop the process that‘s listening on port 8080 or configure this application to listen

闲言 870

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

Verify the connector‘s configuration, identify and stop any process that‘s listening on port 8080, o

在idea的运行SpringBoot项目时,出现Verify the connector’s configuration, identify and stop any process that’s listening on port 8080, or configure this application to listen on another port. 说tomcat端口被占用了,我去cmd里netstat -ano|findstr "8080"和tasklist|findstr "8080"回去运行,

m0_48020754的博客 1062

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

maven工程创建的springboot中提示Identify and stop the process that‘s listening on port 8080解决方法

直接在resource目录下创建新建一个application.properties,并输入server.port=8081 springboot中没有application.properties文件解决方法 添加链接描述

weixin_44595122的博客 2107

spring boot在起web(Tomcat)时报Identify and stop the process that‘s listening on port 8080

在起项目时报下面异常,这是因为我本地起着nginx呢(忘了nginx我设置的是开机自启动),占用着8080端口,用于前端Vue的开发, 所以直接修改yml/properties配置文件中的端口重新启动就可以了 下面是报的错误 2021-02-24 15:56:16[ restartedMain:30784 ] [] - [ERROR] org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter-report:40 - APPLI

胖墩的IT博客 699

SpringBoot起服务报错

报错日志如下 Identify and stop the process that's listening on port 8080 or configure this application to listen on another port. [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ---------------------

JaydenKey的博客 690

【BUG日记】【Idea】运行Spring项目报错“Web server failed to start. Port 8080 was already in use.”(二)

【日期】:2020/4/7 【问题】:续上次修改端口后,重启后,又发现新的错误 APPLICATION FAILED TO START   Description:   Web server failed to start. Port 8080 was already in use.   Action:   Identify and stop the process that’s listeni...

南方者的博客 2424

mac启动springboot失败,8080端口被占用,mac命令行关闭端口

如下图,idea启动springboot失败,8080端口被占用 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2018-05-23 22:18:43.688 ERROR 3793 --- [  restartedM...

andy_jiangbin的专栏 1194

IntelliJ IDEA 2024.1.1 中快速创建 Spring Boot 项目的指南【图文教程】

《IntelliJ IDEA 2024.1.1 快速创建 Spring Boot 项目指南》摘要: 本文详细介绍了使用 IntelliJ IDEA 2024.1.1 创建 Spring Boot 项目的完整流程。Spring Boot 作为简化 Spring 开发的框架,结合 IDEA 的强大功能(如 Spring Initializr 模板、热部署、代码生成),可显著提升开发效率。指南涵盖环境准备(JDK11+、Maven)、项目创建步骤(含界面截图)、标准目录结构说明,以及端口修改、接口开发等实战操作,

深耕 Java 后端与企业级软件架构设计,专注微服务、分布式系统、大模型 AI 应用架构落地。 5570
上一篇: SpringBoot - SWAGGER中配置.pathMapping(“XXXX“)引发的404错误
下一篇: SpringBoot - @PreAuthorize注解详解
cloneme01
博客等级 码龄20年 2万+粉丝 248原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cloneme01

谢谢您的支持与鼓励!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值