1. Application servers
To configure a server in the IDE, go toSettings→Application Serversand click theAdd application serverbutton. The IDE will automatically detect its version and ask 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 theWeb 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 inProject Structure→ModulesandProject Structure→Facets.
Usually you don’t need to configure theWeb facetmanually. The IDE automatically detects the descriptors and web resource roots and offers to configure it.
3. Artifacts
An artifact is what the IDE deploys to a server when you run the application viaRun 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 toProject Structure→Artifacts.
If you useMavenorGradle, 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
ARun configurationdefines how the artifacts are deployed to the server. IntelliJ IDEA has two types of Run configurations:LocalandRemote. TheLocalrun configuration starts a new instance of the server and deploys artifacts there. TheRemoterun configuration deploys the artifacts to an already running standalone server.
Each application server may have a different set of parameters in aRun configuration.
One important parameter here isOn ‘update’ action, which defines how to update the application when you use theUpdateaction viaCtrl+F10(Cmd+F10for Mac). Based on your choice, the IDE canupdate resources,update classes and resources, orredeployorrestart the server. Turn off theShow dialogcheckbox 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 theOn 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 canupdate resources,update classes and resources, ordo 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 theExplodedartifact type. For theArchiveartifact type use the commonHotSwap.
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 theBefore launchgroup in theRun configurationdialog.
ARemoterun 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 aRun configurationis created, you can run or debug your application via theToolbar,Runmenu, or the shortcuts:RunviaShift+F10,DebugviaShift+F9.
6. Update and HotSwap
When you need to apply changes in the code to a running application, we recommend using theUpdateaction viaCtrl+F10(Cmd+F10for Mac). As mentioned above, theUpdateaction is only available for theExplodedartifact type. Based on your choice, it canupdate resourcesorupdate classes and resources. When theUpdateaction is applied in theDebugmode, it uses theHotSwap; otherwise, it uses theHot redeployment.
If you use theArchiveartifact type you can only rely on theHotSwap, which is done automatically when you are in theDebugmode.
7. Build artifacts
You can always ask the IDE to build your artifacts on via theBuild→Build artifactsaction.
8. Application servers tool window
EachRun configurationis shown in theApplication serverstool window, along with the server and artifacts state. This tool window also helps you easilyRun/Stopthe server andDeploy/Undeploy/Configureartifacts.