Nice keyboard shortcuts

  • Select In: Alt+Shift+1. To quickly select the current element in any view (Project view, Maven view, etc.)
  • Quick Documentation: Ctrl+Q. To view documentation for whatever object (class, type, etc.) currently at the caret.

Working with version control systems

Resolving conflicts

Useful process for larger projects:

  1. Open the Version Control window using View > Tool Windows > Version Control.
  2. Click Local Changes to show local changes (which will include conflicts)
  3. Click the gear icon and Group By either Directory or Module (makes it easier to just work on merge conflicts in a specific directory or module)


Debugging unit tests using IntelliJ

  1. Create a new Run Configuration in IntelliJ.
  2. Set the command line property to your test Maven goal name, e.g. test
  3. On the Runner tab, set VM Options to: -DforkMode=never
  4. Set any breakpoints in your code
  5. Now Debug your Run Configuration, e.g. Ctrl+D, or Run → Debug ‘my-app [test]’.

Debugging an external application

  1. Choose Run → Edit Configurations.
  2. Add a new Configuration of type Remote. Name it debugging.
  3. Copy the command line arguments for running remote JVM (e.g. -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005)
  4. (Optional) Modify suspend=y to make the Java application wait until the debugger is connected before starting.
  5. (Optional) Set the debug flags in the environment variable JAVA_OPTS.
  6. In a Terminal, start the application to be debugged.
  7. In IntelliJ, start the remote debugger (Run → Debug → debugging).

For example:

java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 -jar target/spring-boot-camel-xa-1.0-SNAPSHOT.jar

Debugging for specific tools/frameworks

Thorntail Maven Plugin

Set the property thorntail.debug.port which causes Thorntail Maven Plugin to suspend on start and open a debugger on this port (when using run or start goals), e.g.:

$ mvn thorntail:run -Dthorntail.debug.port=8000


IntelliJ tries to build the entire project before running a single test:

  1. Run → Edit Configurations
  2. Navigate to JUnit → Your project, and then remove Make from the list of ‘before launch’ tasks.

Cannot resolve classes/objects/dependencies (lots of squiggly red underlines everywhere):

  • Check that the project has been added as a Maven project (right-click the pom.xml → Add as Maven Project)
  • Ensure that IntelliJ is using the correct Maven binary - go to Settings → Maven, and check the path to the Maven installation location, and settings.xml.
  • Check that artifacts can be resolved correctly. Drop to a Terminal and, using the same Maven binary configured in IntelliJ, try mvn -U help:effective-pom. If artifacts can’t be resolved here, then fix this first.
  • If you’re pulling artifacts from a Nexus repository, check that it’s able to pull artifacts from the web. Log in to Nexus and check the status of your proxy repositories.
  • Check that maven-compiler-plugin is configured correctly (e.g. with a version number)

Package names aren’t resolving (classes can’t see other classes, etc.):

  • Check that the main and test folders have been added as Sources
  • Right-click the src/main/java folder, right-click → Mark Directory as → Sources Root
  • Right-click the src/test/java folder, right-click → Mark Directory as → Test Sources Root