ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

IDEA部署 java Web项目 常见配置

2019-08-06 18:01:41  阅读:213  来源: 互联网

标签:Web CATALINA java tomcat 项目 部署 IDEA idea 目录


前言

从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_HOME\webapps 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的安装目录。

 

标签:Web,CATALINA,java,tomcat,项目,部署,IDEA,idea,目录
来源: https://www.cnblogs.com/BoildWater/p/11310737.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有