Start the AEM server using the following command:
$ CQ_JVM_OPTS='-server -Xmx2048m -XX:MaxPermSize=2048M -Djava.awt.headless=true -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=30303' ./start
Go to Run/Debug Configurations, Click + icon and Click Remote
Make sure the port number matches with the port number used in the start command.
Select the debug configuration and click on the debug icon.
You can add breakpoints in the code and start debugging the code
Full course available on https://www.donotstoplearning.com