Tomcat手動啟動/部署[非安裝版]

ko_y0715發表於2017-07-28

Tomcat手動啟動/部署[非安裝版]

寫在前面的話:
以前做JavaWeb開發時習慣了,用Eclipse或者Idea等開發工具開發,除錯程式碼. 基本上以來工具的Tomcat外掛就很方便的實現了專案的釋出/啟動.

後來, 想自己寫一些靜態頁面時,不知道如何手動去部署/啟動Tomcat,網上找了下,似乎不是那麼容易找到.這裡自己備註一下, 以便下次查閱.

*確保自己JDK已經安裝好, 即已經配置好Java環境, 驗證是否已安裝:命令視窗執行:java -version 可成功執行,顯示自己安裝JDK的版本即表示已配置java環境.

  • 將自己要部署的專案打成war包/靜態頁面,將war包/靜態頁面放置在tomcat的webapps包下面
    …\Apache\Tomcat\apache-tomcat-7.0.64\webapps
    類似這樣的目錄下

然後找到bin目錄下startup.bat,並編輯,加入:set JAVA_HOME=H:\Program Files\java\jdk1.8

@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.  See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License.  You may obtain a copy of the License at
rem
rem     http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem ---------------------------------------------------------------------------

setlocal

rem Guess CATALINA_HOME if not defined
set JAVA=H:\Program Files\java\jdk1.8
set "CURRENT_DIR=%cd%"

如上所示,然後儲存關閉,右鍵以管理員身份啟動該bat檔案即可

然後在瀏覽中輸入 localhost:8080/hello.html

寫在後面的話,第一次寫部落格,有不好的地方請指出.thx

相關文章