前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >使用idea打包springcloud项目并部署到tomcat下

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

作者头像
伍六七AI编程
发布2019-10-08 18:45:04
1.8K0
发布2019-10-08 18:45:04
举报
文章被收录于专栏:preparedprepared

说明:有三个项目,

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

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

一个web服务-appsweb

使用 idea 打成 war 包:

代码语言:javascript
复制
build->build artifacts-->选择 all 或者选择单个

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

代码语言:javascript
复制
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 地址)

代码语言:javascript
复制
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

缺什么加什么即可。

代码语言:javascript
复制
@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,这样方便检查错误以及修改代码改正错误。

本文参与?腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客?前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 使用 idea 打成 war 包:
  • 部署到 tomcat
    • 前置工作
      • 启动 tomcat
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
      http://www.vxiaotou.com