idea运行springboot项目的时候端口号冲突

1、错误原因
idea运行springboot项目的时候端口号冲突,springboot项目是使用内置的Tomcat服务器。

2、错误信息

2021-05-06 17:25:06.480  WARN 1764 --- [           main] ConfigServletWebServerApplicationContext :
 Exception encountered during context initialization - cancelling refresh attempt: 
 org.springframework.context.ApplicationContextException: 
 Failed to start bean 'webServerStartStop'; nested exception is 
 org.springframework.boot.web.server.PortInUseException: Port 8080 is already in use

3、解决办法(1和2随便选用一种方法就行)

  1. 在resources目录下写一个yaml文件,在yaml文件里面修改Tomcat的端口号。
    application.yaml文件的内容:
server:
  port: 8787
  1. 在resources目录下新建一个properties文件,同上(1)
    application.properties文件内容:
server.port=8989

猜你喜欢

转载自blog.csdn.net/qq_43987149/article/details/116458666