您当前的位置:首页 > 计算机 > 软件应用 > 开发(IDE)

IDEA部署 java Web项目 常见配置

时间:12-11来源:作者:点击数:
CDSY,CDSY.XYZ

一:添加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:

在这里插入图片描述

也就是说,

当你把这个框给勾上时,此时在你启动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的安装目录。

CDSY,CDSY.XYZ
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门