1. Application servers
To configure a server in the IDE, go to Settings → Application Servers and click the Add application server button. The IDE will automatically detect its version and offer you to select which libraries to add to the dependencies when the server is used in the project.
2. Web facet
One important thing when working with an application server is the Web facet. This is where the IDE stores the web settings for each module of your project. These settings include the deployment descriptors and web resources roots, and are available in Project Structure → Modules and Project Structure → Facets.
Usually you don’t need to configure the Web facet manually. The IDE automatically detects the descriptors and web resource roots and offers to configure it.
An artifact is what the IDE deploys to a server when you run the application via Run configurations. Each artifact has its name, type, output directory, layout and type (Web Application: Archive, Web Application: Exploded, EJB Application: Archive, EJB Application: Exploded, etc). To configure the artifacts, go to Project Structure → Artifacts.
If you use Maven or Gradle, you don’t need to configure the artifacts manually. The IDE automatically synchronizes them with the artifacts defined in your build files.
4. Run configurations
A Run configuration defines how the artifacts are deployed to the server. IntelliJ IDEA has two types of Run configurations: Local and Remote. The Local run configuration starts a new instance of the server and deploy artifacts there. The Remote run configuration deploys the artifacts to an already running standalone server.
Each application server may have a different set of parameters in a Run configuration.
One important parameter here is On ‘update’ action, which defines how to update the application when you use the Update action via Ctrl + F10 (Cmd+ F10 for Mac). Based on your choice, the IDE can update resources, update classes and resources, or redeploy or restart the server. Turn off the Show dialog checkbox if you don’t like to see the dialog each time you update the application. This is a great time-saver when you update your application very frequently.
Another important parameter is the On frame deactivation, which defines how to update the application when you switch from the IDE, say to a browser. Based on these settings, the IDE can update resources, update classes and resources, or do nothing. This setting may be very useful when you’d like to have your application updated automatically each time when you switch to a browser.
Keep in mind that update resources and update classes and resources options are available only for the Exploded artifact type. For the Archive artifact type use the common HotSwap.
By default, the IDE runs the application server using the project JRE. However, you can always choose to use an alternative JRE.
An essential part of any Run configuration is the artifacts deployment.
By default, the IDE automatically builds the artifacts before deploying. However you can change it using the Before launch group in the Run configuration dialog.
A Remote run configuration has additional parameters such as the host/port of the server you’d like to deploy your artifacts to.
5. Run and debug application
Once a Run configuration is created, you can run or debug your application via the Toolbar, menu Run or the shortcuts: Run via Shift + F10, Debug via Shift + F9.
6. Update and HotSwap
When you need to apply changes in the code to a running application, we recommend using the Update action via Ctrl + F10 (Cmd + F10 for Mac). As mentioned above, the Update action is only available for the Exploded artifact type. Based on your choice, it can update resources or update classes and resources. When the Update action is applied in the Debug mode, it uses the HotSwap; otherwise, it uses the Hot redeployment.
If you use the Archive artifact type you can only rely on the HotSwap, which is done automatically when you are in the Debug mode.
7. Build artifacts
You can always ask the IDE to build your artifacts on via the Build → Build artifacts action.
8. Application servers tool window
Each Run configuration is shown in the Application servers tool window, along with the server and artifacts state. This tool window also helps you easily Run/Stop the server and Deploy/Undeploy/Configure artifacts.