By configuring Tomcat with IntelliJ, you can manage key aspects of your development process, such as debugging, logs and hot swapping, all from within the IDE.
This guide assumes you have already installed Tomcat on your machine. Additionally, the Maven, Tomcat and Java EE plugins are required, but they come bundled with IntelliJ and are enabled by default. Unless you have manually disabled them, your environment should be ready.
To ensure a smooth setup, follow these steps to configure your project in IntelliJ:
-
Build with Maven. Run the following commands from the command line:
mvn clean install -f dhis-2/pom.xml -DskipTests=true
if you are using version 2.41 or older, run this command too:
mvn clean install -f dhis-2/dhis-web/pom.xml -DskipTests=true
-
Import Project to IntelliJ:
- Continue by importing the project from your local sources into IntelliJ.
-
Add as Maven Project:
- Right-click on the project's pom.xml and select "Add as Maven Project".
-
If you are on 2.41 or older, configure the Maven Project:
- In the plugin list on the right side, click on Maven.
- Add the web portal project to the list of Maven projects.
- Make sure it's part of the list of modules in
/File/Project Stucture/Modules
. If it's not, add it to the list.
-
Configure Local Tomcat:
- Open the configurations menu and add a new local Tomcat configuration.
- From 2.42 on, you'll need at least Tomcat 10.
- Up until 2.41, use Tomcat 9.0.96 and below.
- In the Deployment tab:
- Open the configurations menu and add a new local Tomcat configuration.
-
Configure Tomcat Settings:
-
Set Environment Variable:
- In the Startup/Connection tab, add a new environment variable called DHIS2_HOME. Repeat this action for the Debug profile too.
- Set the value to your configuration file.
-
Configure Logging (optional):
- Go to the Logs tab and click on Save console output to file.
- Choose a file, preferably the Catalina file of your local Tomcat, to store logs.