IntelliJ Smart Tomcat

The SmartTomcat will auto load the Webapp classes and libs from project and module, you needn’t copy the classes and libs to the WEB-INF/classes and WEB-INF/lib.

The Smart Tomcat plugin will auto config the classpath for tomcat server. The Smart Tomcat support Tomcat 6+.

So here we are going to explain how to install and configure this IntelliJ plugin.

Installation

The first thing you need to do is open the IntelliJ IDE, for this guide the version used is 2021.2.3 or later.

To open the IntelliJ Settings dialog, do the following.

  • In Windows, navigate to File → Settings or press CTRL+ALT+S.

  • In MacOSX, navigate to IntelliJ IDEA → Preferences or press _CMD+,.

Most of the screenshot captures are taken using the Windows OS.

IntelliJ Open Settings Dialog
Figure 1. IntelliJ Open Settings Dialog

Next locate in the options the Plugins choice. Use the search box to locate it quickly as shown next.

IntelliJ Settings Plugins
Figure 2. IntelliJ Settings Plugins

Play special attention that the dialog presents two choices for checking if the desired Plugin is installed or not, notice in the screenshot that it has two tabs, one named Marketplace and the other Installed. If the Plugin is not yet installed it means you need to look for it in the Marketplace tab, typing in the search box the name of the Plugin you need, in this case, Smart Tomcat.

IntelliJ Settings Plugins
Figure 3. IntelliJ Select Smart Tomcat

As indicated in the screenshot, the Smart Tomcat is already installed, but if you happen not to have it already installed in your InteliJ, it would say _Install, which is the action you should take now.

After the plugin is correctly installed then it should appear in the other tab mentioned before.

Configuration

Now that we have the plugin properly configured, let’s add a new Tomcat configuration.

In your IntelliJ locate the Add Configuration…​ option shown next.

IntelliJ Add Configuration
Figure 4. IntelliJ Add Configuration

If the text is not there it means that you already set a configuration to run, so clicking in the same place presents you with other choices.

And it shows the following dialog.

IntelliJ Run/Debug Configurations
Figure 5. IntelliJ Run/Debug Configurations

To create a new configuration just click in the plus icon to the left of the dialog.

IntelliJ Run/Debug Configuration Add New
Figure 6. IntelliJ Run/Debug Configuration Add New

It will present to you with a selection box.

IntelliJ Select Smart Tomcat Configuration
Figure 7. IntelliJ Select Smart Tomcat Configuration

Scroll down to locate the Smart Tomcat configuration to add.

As you may have guessed, Smart Tomcat requires to know the location of your Tomcat Server so he can proceed to put the artifacts therein.

Notice that here we don’t have one defined, so it is now time to declare one as shown next, click on the Configuration button to define one.

Add Tomcat Server
Figure 8. Add Tomcat Server

This opens a dialog to define the Tomcat Server.

Define Tomcat Server
Figure 9. Define Tomcat Server

As shown in the previous imaga, there are no servers defined, so click the indicated button, where it will ask you the location in your file system where you have installed/configured your Tomcat Server.

Define Tomcat Server Location
Figure 10. Define Tomcat Server Location

Click on the Apply and later the OK button to accept this setting.

It takes you back to previous dialog, expand the drop down box for the Tomcat Server

Choose Tomcat Server
Figure 11. Choose Tomcat Server

What is left is to adjust the settings according to our needs.

Configure Smart Tomcat Server
Figure 12. Configure Smart Tomcat Server

Where:

  1. Indicates the name of the configuration to run/debug.

  2. Choose the appropriate Tomcat server.

  3. A working directory for Smart Tomcat, notice that this folder should not be included in the Git repository, that is, it must be excluded.

  4. Sets the context path for the application, normaly it is the IntelliJ module.

  5. Indicates the memory assigned to the Tomcat process.

  6. Click the Apply button to accept the changes.

  7. Click the OK button to accept the changes and close the dialog.

This is a sample configuration, it may change given your requirements.