GAE/J+IntelliJでローカルサーバーのRemote Debug
Google App Engine(Standard)のローカルに実行されているアプリケーションをIntelliJ IDEA Community版でリモートデバッグする方法です。
上の例ではsuspend=yになっていますが、このsuspendはデバッガが接続されるまでアプリケーションの起動を止めるかどうかを指定しています。[y]を指定するとデバッガを接続するまでアプリケーションは起動しません。[n]の場合は通常と同様に起動します。
起動時に自動的に実行される処理をデバッグするときは[y]にする必要があります。
それ以外は[n]にしておいて、必要な時にデバッガを接続する方が簡単です。[y]にしておくと、デバッガが必要ないときも、デバッガを接続するまでアプリケーションが起動しません。
参考URL)開発サーバーでアプリをテストする
pom.xmlの設定
pom.xmlの<plugin><configuration>に<jvmFlags>を追加します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<plugin> | |
<groupId>com.google.cloud.tools</groupId> | |
<artifactId>appengine-maven-plugin</artifactId> | |
<version>1.3.1</version> | |
</plugin> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<plugin> | |
<groupId>com.google.cloud.tools</groupId> | |
<artifactId>appengine-maven-plugin</artifactId> | |
<version>1.3.1</version> | |
<configuration> | |
<jvmFlags> | |
<jvmFlag>-Xdebug</jvmFlag> | |
<jvmFlag>-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</jvmFlag> | |
</jvmFlags> | |
</configuration> | |
</plugin> |
起動時に自動的に実行される処理をデバッグするときは[y]にする必要があります。
それ以外は[n]にしておいて、必要な時にデバッガを接続する方が簡単です。[y]にしておくと、デバッガが必要ないときも、デバッガを接続するまでアプリケーションが起動しません。
参考URL)開発サーバーでアプリをテストする
Edit Configrationの追加
アプリケーションを起動する
mvnコマンドでアプリケーションを起動します。下の例ではsuspend=yを指定しているのアプリケーションは起動しないでデバッガの起動を待っています。[n]を指定した場合は通常と同じように起動します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mvn clean appengine:run | |
... 略 ... | |
[INFO] GCLOUD: Listening for transport dt_socket at address: 5005 |
デバッガを接続する
![]() |
[Run] > [Debug] |
これで、リモートデバッグが可能になります。
後は普通のデバッグ時と同様にブレークなどが使えます。