使用idea打包springcloud項目並部署到tomcat下

說明:有三個項目,html

一個提供 eureka 服務——ehl-eureka-server1,java

一個數據接口服務——apps-is,web

一個web服務-appswebexpress

使用 idea 打成 war 包:

build->build artifacts-->選擇 all 或者選擇單個

在工做空間下找到 war 包,好比:apache

E:\workspace-mars\mps\mps-apps-is\target

部署到 tomcat

前置工做

準備 3 個 tomcatwindows

備註:也能夠部署在同一個 tomcat 下,可是若是有問題很差排查tomcat

分別部署 ehl-eureka-server1,apps-is,appsweb服務器

一、修改 war 包名爲 application.yml 文件中 server.context-path 的名字app

二、分別修改 tomcat 端口爲 server.port 的端口爲less

ehl-eureka-server1 apps-is appsweb
8761 8762 8765
8009 8010 8011
8005 8006 8007

啓動 tomcat

按照順序:先 eureka,後 appis,最後 appsweb,啓動 tomcat。

雙擊 startup.bat 啓動,若是出現閃退,多是環境有問題,在 startup.bat 最後添加 pause 查看

圖片描述

若是是環境的問題,則能夠在文件最前面加上下面的代碼(修改成本身的 java 地址和 tomcat 地址)

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131

set TOMCAT_HOME=D:\soft\apache-tomcat-8.5.34-windows-x64\apache-tomcat-8.5.34-01

set CATALINA_HOME=D:\soft\apache-tomcat-8.5.34-windows-x64\apache-tomcat-8.5.34-01

缺什麼加什麼便可。

@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

set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_131

set TOMCAT_HOME=D:\soft\apache-tomcat-8.5.34-windows-x64\apache-tomcat-8.5.34-01

set CATALINA_HOME=D:\soft\apache-tomcat-8.5.34-windows-x64\apache-tomcat-8.5.34-01

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

set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat"

rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find "%EXECUTABLE%"
echo This file is needed to run this program
goto end
:okExec

rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs

call "%EXECUTABLE%" start %CMD_LINE_ARGS%

:end

最後若是出現 eureka 和 appis 都沒有問題,webs 網站有問題的話,若是部署的服務器是 windows 系統,則能夠單獨使用 idea 啓動 webs,這樣方便檢查錯誤以及修改代碼改正錯誤。

參考:https://jingyan.baidu.com/art...

相關文章
相關標籤/搜索