Spring Boot 进程守护 修改启动端口号 Spring Boot 监听端口被占用无法启动

使用 java -jar gs-spring-boot-0.1.0.jar 命令启动 spring-boot, 由于默认端口号为8080, 且此端口被tomcat占用, 所以启动时出现以下错误:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

***************************
APPLICATION FAILED TO START
***************************

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.

 

由于没有源码, 不太懂Java开发, 所以从代码内修改端口无法实现.

 

通过搜索 查询到 可以使用启动命令 修改启动端口号, 此方法适用.

 

使用以下命令指定端口8897启动Spring Boot:
java -jar -Dspring.config.location=application.properties -Dserver.port=8896 /usr/local/java_jar/gs-spring-boot-0.1.0.jar

 

进程守护,关闭终端依然可以访问.

nohup java -jar -Dspring.config.location=application.properties -Dserver.port=8896 /usr/local/java_jar/gs-spring-boot-0.1.0.jar  &

 

jar文件的路径 建议使用绝对路径, 这样下次启动比较方便.

 

注:即使application.properties文件中设置了server.port=8080,启动端口也是: 8896


————————————————
参考网址: https://blog.csdn.net/m0_37739193/article/details/83388271 感谢无私分享.

posted @ 2021-06-07 18:44  Aliwall  阅读(506)  评论(0编辑  收藏  举报