经常开发的同学肯定会遇到一个恶心的问题。
MD!明明老子本地是正常的,怎么一上测试环境or生产环境就炸崩崩了。
现在我们来配置远程debug,配完以后我甚至再也不喜欢在本地调试了(手动斜眼)
首先第一步请在linux服务器上的tomcat中bin目录下修改catalina.sh的配置。
export JAVA_OPTS="-server -Xms500m -Xmx500m -Xmn300m -XX:PermSize=128m -XX:MaxPermSize=256m -XX:SurvivorRatio=10 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=70 -XX:+UseCMSInitiatingOccupancyOnly -XX:MaxTenuringThreshold=6 -XX:+ExplicitGCInvokesConcurrent -XX:+ParallelRefProcEnabled -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=1 -XX:-UseBiasedLocking -XX:+UseFastAccessorMethods -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/usr/local/src/logs/dump -XX:+PrintGCApplicationStoppedTime -verbose:gc -XX:+PrintGCDateStamps -XX:+PrintGCDetails -Xloggc:/usr/local/src/logs/dump/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=20M -Duser.timezone=Asia/Shanghai -Djava.security.egd=file:/dev/./urandom -Xdebug -Xrunjdwp:transport=dt_socket,address=8788,server=y,suspend=n"
请在启动参数里配置-Xdebug -Xrunjdwp:transport=dt_socket,address=8788,server=y,suspend=n
然后进入IDEA配置。
选择remote哦。
然后只要把IP和刚才配置的端口号加上就行。
然后点击debug运行。
出现这个界面即代表成功。