zoukankan      html  css  js  c++  java
  • IDEA部署 java Web项目 常见配置

    前言

    从eclipse上转到idea上,第一次使用idea部署web项目,真折磨人,写了一个 helloworld 5分钟,了解idea部署web项目5小时。

    我使用的是idea 2019.1版本,其他版本大致相同,下面一步步进行web项目部署,并且对其中遇到的idea一些常见设置进行解释。

    一:添加Tomcat服务器

    在项目编写完成后,首先要添加一个tomcat服务器

     

     二:部署项目

     

     war与war exploded的区别

    选择war exploded部署好项目后,仍然来到这个页面

    介绍一下 Deploy application configured in Tomcat instance

    Deploy application configured in Tomcat instance 有什么用?

     

    下面是我在Stack Overflow 看到的:

    This setting controls whether the apps you already have present in TOMCAT_HOMEwebapps directory will be deployed when Tomcat is started from IntelliJ IDEA.

    By default that would deploy the following:

    • docs
    • examples
    • host-manager
    • manager
    • ROOT

    If you don't need any of these default apps or any of your other apps put there manually to be deployed, disable the Deploy applications configured in Tomcat instance option. This will make the server startup faster and it will use less memory.

    Documentation page you are looking for is available here, here is the official explanation for this option:

    The Tomcat configuration files, among other things, may list the applications that should be deployed at the server start. If this check box is selected, all the applications so listed will be deployed on the server in addition to the artifacts specified on the Deployment tab. If the check box is not selected, only the artifacts and the external resources specified on the Deployment tab will be deployed.

    也就是说,

    当你把这个框给勾上时,此时在你启动tomcat服务器后,不仅会部署你当前的项目,而且还会部署在 ${tomcat安装目录}/webapps/ 下的其他项目,例如tomcat出厂就自带的docs examples等项目,tomcat部署完成后,你只访问 localhost:8080 就能成功进入tomcat首页,是因为,你在部署你当前项目的同时,还部署了webapps目录下的root 项目。

    如果没有勾上这个框,那么你访问localhost:8080会抛出404,你只能访问你当前项目的全路径,拿我的来说就是:localhost:8080/springmvc01_helloworld/  才不会抛出404错误。

     

    三:查看tomcat启动后,控制台打印信息,CATALINA_BASE与CATALINA_HOME

    这里,主要关注CATALINA_BASE和CATALINA_HOME两个目录,这两目录有什么区别?

    简单来说,

    CATALINA_BASE是idea为当前项目建立的工作目录,我们部署的项目就放在这里(上面的设置介绍中,我有提到),使用war exploded部署项目时,并没有把项目打包到tomcat的webapps目录下,我们的项目部署的位置就在这儿!!! 查看这个目录有什么?

    看看conf目录里面有什么?竟然还有tomcat的配置文件server.xml

    对比一下tomcat的安装目录:

    看到这里就明白了一件事,idea为每个部署的项目新创建了一个tomcat实例,这就是一个工作目录,这个实例与我们的tomcat相比,没有bin和lib库等信息,只有一些配置信息,仍然与原来tomcat共用bin和lib目录。

    CATALINA_HOME则是tomcat的安装目录。

     

  • 相关阅读:
    c#类的小小理解
    sql语句:保留要害字的问题.例如 size,text,user等
    c#2005做新闻发布系统心得
    asp 遇到过的问题集锦,附加asp语句添加数据库和生成表,asp命令更改指定文件的文件名,asp值传递的应用091116小结
    dropdownlist控件失去焦点的小应用和函数substr
    获得当前应用程序路径C#03
    模糊查询简单分析,得出sql语句
    20080905经典的DataReader对象解读+几种对数据库的操作的命令,20100111update read db example
    Servlet 容器的工作原理 ( 二 )
    手低眼高 初学者学习Hibernate的方法
  • 原文地址:https://www.cnblogs.com/BoildWater/p/11310737.html
Copyright © 2011-2022 走看看