mac m1上Tomcat已经启动,但是8080端口无法连接

问题描述

虽然tomcat hava启动了,但是locahost:8080连接不上 enter image description here enter image description here

我尝试了一些方法,例如: 1、关闭8080端口,8080端口不使用。 enter image description here 2、在.zshrc文件中配置路径,但是没有用。

解决方法

首先使用ps -ef | grep java命令查看Tomcat进程是否存在。如果它不存在,请检查日志 logs/catalina.out 以找出错误消息。
然后确定你的Tomcat是否使用端口8080来处理HTTP请求。您可以在日志文件中找到类似的文本:

06-Jun-2021 12:58:12.264 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8081"]

我将 HTTP 端口更改为 8081,因此日志显示 http-nio-8081。您可以在文件 conf/server.xml:

中查看/更改端口
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL/TLS HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
,

至少jdk不适合tomcat,需要安装jdk1.8才能解决这个问题。这是美妙的一天。