运行Spring Boot应用程序时"正在使用地址:绑定"

rez*_*tin 3 spring-boot

我在运行示例Spring Boot Application时遇到问题.当我尝试运行它时,会发生以下错误:

 java.net.BindException: Address already in use: bind
            at sun.nio.ch.Net.bind0(Native Method)
            at sun.nio.ch.Net.bind(Unknown Source)
            at sun.nio.ch.Net.bind(Unknown Source)
            at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
            at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
            at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:473)
o.apache.catalina.core.StandardService   : Failed to initialize connector [Connector[org.apache.coyote.http11.Http11NioProtocol-8080]]

    org.apache.catalina.LifecycleException: Failed to initialize component [Connector[org.apache.coyote.http11.Http11NioProtocol-8080]]
            at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
            at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
            at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
            at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
            at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
            at org.apache.catalina.startup.Tomcat.start(Tomcat.java:335)
            at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:57)
            at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:52)
            at 
Run Code Online (Sandbox Code Playgroud)

dun*_*nni 6

"已在使用的地址"表示已经有另一个应用程序在端口8080上运行.使用您的操作系统工具查找该进程并在启动应用程序之前结束它,或让您的应用程序在另一个端口上运行.如果在Boot应用程序中使用嵌入式服务器,则可以指定以下属性:

server.port=8085 
Run Code Online (Sandbox Code Playgroud)

当然你可以选择你想要的任何端口.


小智 6

在你第一次运行正常吗?并再次运行它有一个错误?如果正确,您需要在再次运行之前停止服务.这是停下来的方法.点击按钮停止看起来像这个图像 在这里输入图像描述