使用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-server1apps-isappsweb
876187628765
800980108011
800580068007

启动 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

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

伍六七AI编程

你猜你给我1分我要不要

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值