我想知道是否可以启动SpringBoot应用程序。在80端口中,
我已将端口设置为80,server.port=0080
但是在启动应用程序时出现错误。
2019-03-31 12:52 [restartedMain] INFO o.a.coyote.http11.Http11NioProtocol.log(173) - Starting ProtocolHandler ["http-nio-80"]
2019-03-31 12:52 [restartedMain] ERROR o.a.catalina.util.LifecycleBase.log(175) - Failed to start component [Connector[HTTP/1.1-80]]
org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1008)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:226)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:259)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:197)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:311)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:164)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)
at io.icrypts.ICryptsApplication.main(ICryptsApplication.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.net.BindException: Address already in use
答案 0 :(得分:1)
编号为0–1023的端口称为系统端口或众所周知的端口。
这些是保留的端口,您不应在该端口范围内运行应用程序。
在您的例外情况下,您可以阅读:
Caused by: java.net.BindException: Address already in use
这意味着已经有一个使用端口80的服务。您无法在该端口上绑定应用程序,除非您找到已绑定的服务并将其杀死。
同样,不建议将端口0–1023用于自定义应用。
正如已经建议的那样,最好在端口80上使用apache或nginx设置将请求转发到您的应用程序(应在1024–49151范围内的端口上运行)。 here中提供了如何设置将80转发到8080的反向代理的示例。