到达tomcat的conf目录下,找到service.xml文件
2、找到对应设置端口的代码修改port端口,这里设置为端口号为8894
<Connector port="8894" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"/>
假如系统环境变量已经配置了JAVA_HOME和CATALINA_HOME的话,而且只有一个tomcat直接到bin目录下面先shutdown.bat再点击startup.bat即可(Liunx则shutdown.sh和startup.sh)
假如存在多个tomcat,直接改变点击startup是没有用的,startup默认读取系统环境变量中的JAVA_HOME和CATALINA_HOME。修改方法则进入bin目录下面找到startup.bat,右键编辑,在其中加set "CATALINA_HOME=D:\apache-tomcat-8.5.47-8894"一行代码指定CATALINA_HOME的目录,将后面的目录修改为自己本地的tomcat路径。
setlocal
set "CATALINA_HOME=D:\apache-tomcat-8.5.47-8894"
rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
cd ..
set "CATALINA_HOME=%cd%"
cd "%CURRENT_DIR%"
:gotHome
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome
双击运行startup.bat,当在黑框框中看到其读取的是CATALNA_HOME是正确的即可