IntelliJ IDEA Tomcat Configuration


English version steps

  1. Open IDEA

  1. Click on the “Edit configuration” option of the current project

  1. In the upper left corner “+” find the “Tomcat Server” option, select “local” (local can only be accessed by yourself)

  1. Configure “Name” at the top right

  1. Application server configuration.
    1. https://tomcat.apache.org/download-90.cgi, download the zip from the official website, unzip it to an empty folder of your choice
    2. Back to IDEA, select the path of apache.tomcat folder you just extracted.

  1. uncheck “After launch” (optional), JRE select 1.8 (for me will be an error, or the default on the line, mine is 16), port: “HTTP port 8080”, JMX. “port 1099”

  1. Click on “Deployment” in the bar above, select “Artifact” from the “+” on the right, then make sure your project ends with this “-web:war exploded” (must end in exploded) click OK, then pull down to “Application context” and change the name: remove the “_war_exploaded” delete (optional, here for convenience), and then click OK.




Potential problems and solutions

If the JavaWeb project reports an error:

can not resolve symbol

That is, you need to configure tomcat.

  1. Create a new Tomcat (here remember not the “TomcatEE”, do not choose the wrong server).

  1. Configure the “application server” (if you find that it is already configured, click “configure”, (check the content of the “library” below, if it is empty, you need to delete the current configuration and then click “configure” to configure again).

  1. After the configuration, “deployment” –> “artifact” (there may not be any options, see the following section for the solution), if it still shows that error, open “project structure” -> “modules” -> “your current module “ -> “dependencies” -> “+” -> “Libraries”->”Application server libraries”->select Tomcat -> tick the box on the left -> Apply and ok.

  1. Problem solved.

If “Deployment”–>”+” in Tomcat configuration does not show the option “Module name:war exploded”:

  1. Open “Project Structure”–>”Artifacts”–>”+”–>”Web Application: Exploded”–>”From Modules”–>Select it–>Apply and OK.

  1. Back to the Tomcat configuration, you can now add the Module you want to deploy in “deployment”.

  1. Problem solved.

中文版本步骤

Tomcat 配置

  1. 打开IDEA

  1. 点击当前项目的“Edit configuration”选项

  1. 在左上角“+”号 找到“Tomcat Server”选项,选取“local”即可(local只能自己访问)

  1. 右侧上方配置“Name”

  1. Application server的配置:
    1. https://tomcat.apache.org/download-90.cgi
      官网下载zip,解压到你自己选取的一个空文件夹
    2. 回到IDEA,选取你刚解压缩后apache.tomcat文件夹的路径。

  1. 取消勾选“After launch”(可选),JRE选取1.8(对我而言会出错,或者默认就行了,我的是16),端口:“HTTP port 8080”,JMX:“port 1099”

  1. 上方bar中点击“Deployment”,右边“+”选取“Artifact”,然后确保你的项目以这个结尾“-web:war exploded”(必须是exploded结尾)点击OK,然后拉到下面“Application context”改个名字:把后面的“_war_exploaded”删除(可选,这里为了方便),然后点击OK即可




潜在问题以及解决方案

如果JavaWeb项目报错:

can not resolve symbol

那就是需要配置tomcat。

  1. 新建Tomcat。(这里记住不是那个“TomcatEE”,不要选错了)

  1. 配置“application server”(如果发现已经配置,点击“configure”,检查下下方“library”是否存在内容,如果为空则需要删除当前的配置然后重新点击“configure”配置一遍)。

  1. 配置好后,“deployment”选择 “artifact”(可能会出现没有任何选项的情况,解决方法看下面的部分),如果还是显示那个错误的话,打开 “project structure”—> “modules”—>“你的当前项目”—>“dependencies”—>“+”—>“Libraries”—>“Application server libraries”—>选择Tomcat—>左边打勾—>Apply and ok。

  1. 问题解决。

如果Tomcat配置中的”Deployment”–>”+”–>不显示选项”Module name:war exploded”:

  1. 打开”Project Structure”–>”Artifacts”–>”+”–>”Web Application: Exploded”–>”From Modules”–>选取即可–>Apply and OK。

  1. 回到Tomcat配置的地方,你就可以在deployment中添加要部署的Module了。

  1. 问题解决。

Author: Anti-General
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Anti-General !
R
Comment
  TOC