SpringBoot启动端口经常被占用解决方法

问题:

启动SpringBoot项目后发现启动失败,控制台输出以下内容

Description: The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured. Action: 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.’

打开命令窗口,输入netstat -ano| 8080,查看占用端口的进程的pid

Windows 下杀指定进程taskkill -F /pid xxxx

如果不想出现如上问题或者换了端口亦然被占用,下面的办法可以解决问题。

1、使用端口号:0 (随机端口)

2、添加依赖:

		<dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-actuatorartifactId>
        dependency>

你可能感兴趣的:(技术难题,spring,boot,java,spring)