如何用Spring Boot自动释放8080端口

6qqygrtg  于 2021-07-23  发布在  Java
关注(0)|答案(2)|浏览(325)

我正在运行基本的spring boot mvc应用程序,每次重新启动应用程序时,我都必须手动关闭端口8080,否则spring boot应用程序将无法运行它会出现以下错误:

Execution failed for task ':DemoApplication.main()'.
> Process 'command 'C:/Program Files/Java/jdk-11.0.3/bin/java.exe'' finished with non-zero exit value 1

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

tomcat不应该在应用程序关闭后立即关闭并释放端口8080吗?

ui7jx7zq

ui7jx7zq1#

在intellij中,转到运行/编辑配置…/tomcat server/local/shutdown script指定用于释放端口的脚本。
或者,您可以编辑原始的tomcat配置,例如 d:\dev\apache-tomcat-8.0.36\conf\server.xml ,就像这样: <Server port="8080" shutdown="SHUTDOWN"> .

3pvhb19x

3pvhb19x2#

考虑到您使用intelij,很可能您有一些错误的可运行配置。
在这种情况下,只需访问spring boot应用程序类并点击绿色按钮即可从那里运行。这将解决您的问题,因为它将自动创建新的可运行配置

相关问题