How to deploy war file to tomcat using command prompt?

后端 未结 8 802
慢半拍i
慢半拍i 2021-01-30 11:05

I have created a war file and put into tomcat/webapps. How to deploy a war file to tomcat using command prompt?

相关标签:
8条回答
  • 2021-01-30 11:43

    i tried this it works quite well

    curl --request PUT --upload-file webapp.war --basic --user user:password \
      http://hostname:port/manager/text/deploy?path=/web_path\&update=true
    

    it is based on the published tomcat manager API: https://tomcat.apache.org/tomcat-9.0-doc/manager-howto.html#Deploy_A_New_Application_Archive_(WAR)_Remotely

    0 讨论(0)
  • 2021-01-30 11:44

    To do this, we need to place the WAR file inside the Tomcat CATALINA_HOME/WEBAPPS/ directory. Later, Tomcat will automatically deploy and explode this WAR file.

    • Change active directory of command prompt to your WAR file location
    • Set CATALINA_HOME variable to the path of the Tomcat directory
    • Copy the WAR files

    Syntax to copy the WAR file from the current directory in the command line:

    copy <your-war-file-name> %CATALINA_HOME%\<your-appBase-name>
    

    Example:

    cd C:\MY_WAR_FILE_LOCATION
    set CATALINA_HOME="C:\Program Files\Apache\apache-tomcat-7.0.42"
    copy MYWARFILE.WAR %CATALINA_HOME%\webapps
    

    Note: If a WAR file is copied into the webapps directory while Tomcat is running, it will not be recognized. Simply restart Tomcat to begin using the web application.

    0 讨论(0)
提交回复
热议问题