跑若依项目的时候,突然遇到的。在网上找了很多方法,看日志也以为是 maven 插件的原因,但是试了将 maven-plugin 改成 1.6.0,直接报错。
网上有方法说不要运行 main 方法,我试了一下,改成 junit 运行,日志打印 8080 端口被占用
org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.PortInUseException: Port 8080 is already in use
cmd 查看了一下明确是这样的
kill进程
成功运行!
但是这个只能每次手动的去 kill 端口,挺麻烦的。。。。
补一补在网上看到的其他方法
方法一 关闭交给 maven 托管,这样可以用 main 方法
方法二 走 @Test 利用 junit 测试代码,不要在 maven 中 运行 main 方法