Appendix D. Instructions for IntelliJ IDEA Users

D.1. Configuring the IDE

D.1.1. Configure a JDK

The first thing you have to do after installing IntelliJ IDEA is configure a JDK.

To see the list of preconfigured JDKs click the Configure button in the Quick Start panel of the Welcome screen.

Select JDK - Step 1

Figure D.1. Select JDK - Step 1



The window contents slide across.

Now choose Project Defaults

Select JDK - Step 2

Figure D.2. Select JDK - Step 2



And finally Project Structure

Select JDK - Step 3

Figure D.3. Select JDK - Step 3



In the Project Structure dialog switch to the SDKs section. Here you can add a JDK by clicking the plus button:

Select JDK - Step 4

Figure D.4. Select JDK - Step 4



Make sure you have configured at least one JDK before you import the project.

D.1.2. Specify Maven local repository

Before you import the project, be sure to specify the Maven repository found within the courseware installation folder or directory. To do that, click the Configure button on the Welcome screen, and then choose Settings (or Preferences for MacOS).

In the Settings dialog:

  1. Switch to the Maven tab;

  2. Select the Override checkbox next to the Local repository setting; and

  3. Specify the path to the Maven repository folder, a sub-folder of the course installation folder.

The default course installation folder is:

  • MS Windows: C:\<course-name>

  • MacOS: /Applications/<course-name>

  • Linux: /home/<user-name>/<course-name>

Setup a Local Repository for Maven

Figure D.5. Setup a Local Repository for Maven



This example shows core-spring-4.0.b.RELEASE on MacOS.  The full path is:

    /Application/core-spring-4.0.b.RELEASE/repository

Here are some more examples for different courses and releases:

  • MS Windows: C:\spring-web-4.0.a.RELEASE\repository

  • MacOS: /Applications/enterprise-spring-4.0.a/repository

  • Linux: ~/core-spring-4.0.b.RELEASE/repository

Remember this location if you are asked to configure M2_REPO later.

D.1.3. Configure a Tomcat application server

As you will need to run web applications during the course, make sure you’ve configured a Tomcat application server. To see the list of configured application servers, return to the Settings/Preferences dialog and switch to the Application Servers tab. Click the plus button to add an application server:

Configure Tomcat

Figure D.6. Configure Tomcat



D.2. Importing the project into the IDE

To import a project into IntelliJ IDEA click the Import project button on the Welcome screen:

Import Projects

Figure D.7. Import Projects



D.2.1. Importing a Maven project

When the project you’re trying to import has a root pom.xml file (which means this is a Maven project), then you have to choose this pom.xml file in the dialog that appears after you’ve clicked the Import project button.

Our courses contain many sub-projects, each with their own pom.xml.  Make sure to pick the parent POM, located in the folder that holds all the projects as shown.  The parent folder is:

  • MS Windows: C:\<course-name>\<course-name>

  • MacOS: /Applications/<course-name>/<course-name>

  • Linux: /home/<user-name>/<course-name>/<course-name>

The example below shows The example below shows the location of the parent POM for core-spring-4.0.b.RELEASE on MacOS.  Its full path is:

/Application/core-spring-4.0.b.RELEASE/core-spring-4.0.b.RELEASE/pom.xml

Import using Maven POM

Figure D.8. Import using Maven POM



On MS Windows the same file would be at:

    c:\core-spring-4.0.b.RELEASE\core-spring-4.0.b.RELEASE\pom.xml

D.2.2. Importing Eclipse projects

When the project comes with no root pom.xml file you can import it as an Eclipse project using its .classpath file. In our case there is more than one project, so choose the entire root folder:

Import Eclipse Projects - Step 1

Figure D.9. Import Eclipse Projects - Step 1



After you’ve chosen the folder, the IDE will ask you which external model to use for the import. Make sure you’ve selected Eclipse:

Import Eclipse Projects - Step 2

Figure D.10. Import Eclipse Projects - Step 2



If there are several projects in the folder, the IDE will ask you to select the projects to import:

Import Eclipse Projects - Step 3

Figure D.11. Import Eclipse Projects - Step 3



At this point IntelliJ IDEA may prompt you to set the M2_REPO variable.  Set this variable to point to the 'repository' folder within the install folder (the same location that we configured earlier). Once set, you should now see all of the Eclipse projects as modules within IntelliJ.

Import Eclipse Projects - Step 4

Figure D.12. Import Eclipse Projects - Step 4



Finally, after the IDE has imported the project, make sure it is compiled without errors. Once the import is finished the IDE may ask you to restart the IDE, please do it.

D.3. Running applications and tests

D.3.1. Deploying web applications

To run a web application, deploy the corresponding artifact to the application server. A Run configuration defines how artifacts are deployed to a server. Go to the Run → Edit Configurations menu, and add a Local Tomcat configuration. The Local run configuration will start a new instance of the configured server and deploy artifacts there.

Deploy Web Project - Step 1

Figure D.13. Deploy Web Project - Step 1



Then switch to the Deployment tab and add the artifacts by clicking the plus button:

Deploy Web Project - Step 2

Figure D.14. Deploy Web Project - Step 2



Select the artifacts you’d like to deploy to the server:

Deploy Web Project - Step 3

Figure D.15. Deploy Web Project - Step 3



D.3.2. Running tests

To run all tests from a package or the entire project, simply select Run ‘All Tests’ from the context menu in the Project tool window:

Run Tests

Figure D.16. Run Tests



If you want to run tests from a single class, use the corresponding action from the context menu for that particular class. To use specific parameters for running tests, you can create a run configuration manually via the Run → Edit Configurations menu.

D.3.3. Running applications

To run an application from its main method, use the corresponding context menu action:

Deploy Application

Figure D.17. Deploy Application



Or create a run configuration manually via the Run → Edit Configurations menu.

D.3.4. Working with TODOs

To see the list of TODO instructions, use the TODO tool window, which can be opened from the left-hand bottom corner of the IDE. Use the toolbar buttons to group items by module:

View TODO Steps

Figure D.18. View TODO Steps



D.3.5. Other Resources

Refer to the following resources to learn more about IntelliJ IDEA: