[英]Debugging Google App Engine app in Intellij
我正在阅读Google App Engine for Java的“Hello World”教程。 通过执行以下操作在浏览器中运行应用程序时,一切正常:
mvn appengine:devserver
在我的浏览器中,我刚刚启动:
http://localhost:8080
但是在Intellij中,当我运行Debug时,浏览器会打开,但页面无法显示(错误403)。
我认为问题与Intellij中项目配置的方式有关。 请参阅我的调试设置的附加屏幕截图:
当我输入Maven命令时,我不清楚Maven命令使用了什么应用程序服务器,当我从Intellij运行它时使用了哪一个。 Intellij似乎确实使用了Jetty。 以下是Intellij中Application Server设置的快照:
这是pom.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2015 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>com.example.appengine</groupId>
<artifactId>appengine-helloworld</artifactId>
<!-- Parent POM defines ${appengine.sdk.version} (updates frequently). -->
<parent>
<groupId>com.google.cloud</groupId>
<artifactId>doc-samples</artifactId>
<version>1.0.0</version>
<relativePath>../..</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<!-- for hot reload of the web application -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<version>3.3</version>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.sdk.version}</version>
</plugin>
</plugins>
</build>
</project>
我如何解决这个问题,以便我可以在Intellij中运行Debug?
您正在使用Maven运行您的开发服务器,因此您需要设置远程调试配置。
您将看到它正在侦听端口5005,因此您需要确保pom.xml
的App Engine插件部分具有相同端口号的此部分:
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.sdk.version}</version>
<configuration>
<-- other config stuff here -->
<jvmFlags>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005</jvmFlag>
</jvmFlags>
</configuration>
</plugin>
您可以正常启动开发服务器(在端口8080或您在pom中配置的任何内容),但现在您可以在代码中放置一个断点,当您触发该段代码时(例如,转到浏览器中的页面),你可以在调试器中单步执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.