File this post under “stuff-I-google-repeatedly”. I’m posting this so it will pop up the next time I’m searching for it in 3 months time.
Firstly, configure IntelliJ:
Run > Edit Configurations…
Add New Configuration (Type: Remote)
Keep all defaults & Just change the port to 8000
Secondly, switch to CLI:
cdinto the project’s directory
mvnDebug clean install
This will produce an output like this:
Preparing to Execute Maven in Debug Mode Listening for transport dt_socket at address: 8000
mvnDebug is very similar to the classic
mvn command apart from the crucial difference that it will wait for a debugger to be attached to the Java process before continuing execution.
Lastly, switch back to IntelliJ:
- Set your breakpoints & Run the new configuration
A new debugger session will be created and attached to the Java process on port 8000. If you switch back to the terminal, you can actually see the Maven command being resumed (i.e. logs are being printed out).