使用idea打包springcloud项目并部署到tomcat下

说明:有三个项目,

一个提供 eureka 服务——ehl-eureka-server1,

一个数据接口服务——apps-is,

一个web服务-appsweb

使用 idea 打成 war 包:

build->build artifacts-->选择 all 或者选择单个

在工作空间下找到 war 包,比如:

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

部署到 tomcat

前置工作

准备 3 个 tomcat

备注:也可以部署在同一个 tomcat 下,但是如果有问题不好排查

分别部署 ehl-eureka-server1,apps-is,appsweb

1、修改 war 包名为 application.yml 文件中 server.context-path 的名字

2、分别修改 tomcat 端口为 server.port 的端口为

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/article/a24b33cd10adf719fe002ba1.html

猜你喜欢

转载自blog.csdn.net/Prepared/article/details/83027106