服务器启动jar包报错:
shell
ork.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
:Caused by: java.net.BindException: 地址已在使用
我启动服务的命令是:
shell
nohup java -jar xxx.jar &
解决方案:
很可能是:之前启动的 nohup java -jar xxx.jar 进程没有完全停止 或者有其他服务占用了相同端口
- 查找并终止占用端口的进程
shell
sudo lsof -i :8080
2. 如果找不到,可能是进程卡住了,强制终止Java进程
shell
pkill -f xxx.jar
shell
pkill -f java
等待几秒 sleep 3
重新启动
nohup java -jar xxx.jar > app.log 2>&1 &
5. 查看日志
tail -f app.log