我想在批处理文件中配置apache tomcat(任何版本)。 我正在做一个项目,有必要这样做。如果是手动操作,则更改端口有效,但按批处理脚本自动运行则不起作用...我尝试将其输入:
echo A configurar o tomcat6...
setx CATALINA_HOME "C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.53"
COPY tomcat6-shutdown.bat "C:\Program Files\Apache Software Foundation\tomcat6-shutdown.bat"
COPY tomcat6-start.bat "C:\Program Files\Apache Software Foundation\tomcat6-start.bat"
RD /S /Q "C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.53\work"
RD /S /Q "C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.53\webapps\docs"
RD /S /Q "C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.53\webapps\manager"
RD /S /Q "C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.53\webapps\ROOT"
cd "C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.53\temp"
del safeToDelete.tmp
cd "C:\Program Files\Apache Software Foundation"
mkdir Tomcat6_instance
Xcopy /E /I "C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.53\conf" "C:\Program Files\Apache Software Foundation\Tomcat6_instance\conf"
Xcopy /E /I "C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.53\temp" "C:\Program Files\Apache Software Foundation\Tomcat6_instance\temp"
Xcopy /E /I "C:\Program Files\Apache Software Foundation\apache-tomcat-6.0.53\webapps" "C:\Program Files\Apache Software Foundation\Tomcat6_instance\webapps"
cd "C:\Program Files\Apache Software Foundation\Tomcat6_instance\webapps"
mkdir test
cd test
(
echo Hello tomcat 6
) > index.html
cd "C:\Program Files\Apache Software Foundation\Tomcat6_instance\conf"
powershell -Command "(gc server.xml) -replace '8005', '8006' | Out-File server.xml"
powershell -Command "(gc server.xml) -replace '8080', '8082' | Out-File server.xml"
powershell -Command "(gc server.xml) -replace '8009', '8010' | Out-File server.xml"
但是此代码根本不起作用。 它替换端口并发送到server.xml,我们还使用setx CATALINA_HOME创建环境变量,当我尝试启动服务器时,服务器没有连接,甚至没有创建服务。 无论如何,我希望对此有所帮助,因为更改端口很重要,在此项目中,我无法通过图形化安装来完成。 有没有创建批处理脚本的方法,或者唯一的方法是通过图形安装? 在我看来,此代码应该可以正常工作,但是当我从端口中的tomcat文件夹中的/ bin文件夹启动startup.bat时,在更改端口后无法启动,但是如果端口为8080,则可以正常工作。