Step 5: Run Configuration
- The Run Configuration in IntelliJ IDEA allows you to define how your application should be executed, debugged, and deployed.
- When working with a web server like Apache Tomcat, setting up a proper run configuration is crucial for testing and development.
- Here’s a detailed step-by-step guide:
- Open Run Configurations:
- In IntelliJ IDEA, go to
Run
>Edit Configurations...
.
- In IntelliJ IDEA, go to
- Add New Configuration:
- Click the
+
icon (usually in the top-left). - Choose
Tomcat Server
>Local
.
- Click the
- Name the Configuration:
- Give it a name (e.g., “MyTomcat”).
- Configure the Server:
- In the “Server” tab:
- Make sure the “Application Server” field shows your Apache Tomcat installation. If it’s not there, click “Configure…” and point to your Tomcat folder (where you extracted the Tomcat zip file).
- In the “Server” tab:
- Deployment Settings:
- Go to the “Deployment” tab.
- Click the
+
icon. - Choose “Artifact…” and select
your-project-name:war exploded
. This means IntelliJ IDEA will deploy your web app directly from the project files. - Application Context:
- Set the “Application context”. For example,
/MyWebApp
means you’ll access your app in the browser athttp://localhost:8080/MyWebApp
.
- Set the “Application context”. For example,
- Save and Run:
- Click “Apply” and then “OK”.
- Select your new configuration from the dropdown menu near the green “Run” button.
- Click the green “Run” button (or press
Shift + F10
) to start Tomcat.