Tomcat本地部署Maven Java Web项目

接下来是在widows部署maven javaweb

首先要配置tomcat,我这里是联合项目,需要配置多个tomcat

选择每个对应的war包

这里的项目名和端口号要改,否则多个项目启动会因为端口号占用无法启动

Tomcat运行项目

打包

在右边的Maven视图里面找到父表题,双击clean之后左边的targer就 会没有了

双击install之后左边就会出现target

配置tomcat

在对应的目录下面找到对应的jar/war包

将这些包复制到对应的tomcat文件夹下面的webapps的文件夹中去

之后去到bin目录下面去双击startup.bat启动tomcat,成功之后就会用对应的war包的文件夹

配置 server.xml

XML 复制代码
<Service name="Catalina1">
  <!-- 每个项目的端口号也要进行区分,保证不被占用 -->
  <Connector port="8084" protocol="HTTP/1.1"
             connectionTimeout="20000"
             redirectPort="8443" URLEncoding="UTF-8"/>
  <!-- 这里的AJP端口同样也要进行区分 -->
  <Connector port="8011" protocol="AJP/1.3" redirectPort="8443" secretRequired=""/>
  <Engine name="Catalina1" defaultHost="localhost">
    <Realm className="org.apache.catalina.realm.LockOutRealm">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
    </Realm>
 
    <Host name="localhost"  appBase="webapps"
          unpackWARs="true" autoDeploy="true">
      <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
             prefix="localhost_access_log" suffix=".txt"
             pattern="%h %l %u %t &quot;%r&quot; %s %b" />
      <!-- 这里是想要部署的对应项目的名称 -->
      <Context docBase="hami_file-1.0-SNAPSHOT" path="/" reloadable="true"/>
    </Host>
  </Engine>
</Service>
  <Service name="Catalina2">
    <!-- 每个项目的端口号也要进行区分,保证不被占用 -->
    <Connector port="8083" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" URLEncoding="UTF-8"/>
    <!-- 这里的AJP端口同样也要进行区分 -->
    <Connector port="8012" protocol="AJP/1.3" redirectPort="8443" secretRequired=""/>
    <Engine name="Catalina1" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
 
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
        <!-- 这里是想要部署的对应项目的名称 -->
        <Context docBase="hami_protal-1.0-SNAPSHOT" path="/" reloadable="true"/>
      </Host>
    </Engine>
  </Service>
 
  <Service name="Catalina3">
    <!-- 每个项目的端口号也要进行区分,保证不被占用 -->
    <Connector port="8082" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" URLEncoding="UTF-8"/>
    <!-- 这里的AJP端口同样也要进行区分 -->
    <Connector port="8013" protocol="AJP/1.3" redirectPort="8443" secretRequired=""/>
    <Engine name="Catalina1" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>
 
      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
        <!-- 这里是想要部署的对应项目的名称 -->
        <Context docBase="hami_console-1.0-SNAPSHOT" path="/" reloadable="true"/>
      </Host>
    </Engine>
  </Service>

添加完成之后保存并且去bin目录先运行tomcat(startup.bat)

相关推荐
一只鱼^_2 分钟前
牛客周赛 Round 99
java·数据结构·c++·算法·贪心算法·动态规划·近邻算法
玩代码1 小时前
CompletableFuture 详解
java·开发语言·高并发·线程
人生在勤,不索何获-白大侠2 小时前
day21——特殊文件:XML、Properties、以及日志框架
xml·java·开发语言
Dcs5 小时前
用不到 1000 行 Go 实现 BaaS,Pennybase 是怎么做到的?
java
Cyanto6 小时前
Spring注解IoC与JUnit整合实战
java·开发语言·spring·mybatis
qq_433888936 小时前
Junit多线程的坑
java·spring·junit
gadiaola6 小时前
【SSM面试篇】Spring、SpringMVC、SpringBoot、Mybatis高频八股汇总
java·spring boot·spring·面试·mybatis
写不出来就跑路6 小时前
WebClient与HTTPInterface远程调用对比
java·开发语言·后端·spring·springboot
Cyanto6 小时前
深入MyBatis:CRUD操作与高级查询实战
java·数据库·mybatis
麦兜*7 小时前
Spring Boot 集成Reactive Web 性能优化全栈技术方案,包含底层原理、压测方法论、参数调优
java·前端·spring boot·spring·spring cloud·性能优化·maven