当托管在 i-Jetty 上时,有谁知道如何调试使用 Android API 的 java servlet?
对于常规网站(不在 Android / i-jetty 上),可以使用 Debug As -> Debug On Server 在本地服务器上使用 Eclipse EE 对其进行调试。
对于 Android 应用程序,我使用 Android Development Tools for Eclipse 并运行 Debug As -> Android Application。
但是,在这种情况下,我将 Android 代码打包在一个战争中。
我使用以下 POM.xml 文件和 maven 来打包 war 文件以与 i-Jetty 一起使用。它运行 dx 实用程序将 servlet 从 Java 转换为 Dalvik。我可以部署结果并在 Android 上的 i-jetty 上运行它。但是,我不知道如何使用除 LogCat 打印输出之外的任何其他方法来调试 servlet 调用。我考虑尝试在 Eclipse 中构建 i-jetty(它也是用 maven 构建的)并查看 ADT 是否可以将执行跟踪到 servlet,但不确定该路径是否会取得成果。
<?xml version="1.0" encoding="UTF-8" ?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
<groupId>org.mortbay.ijetty</groupId>
<artifactId>example-webapps-parent</artifactId>
<version>3.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>blahblah</artifactId>
<name>I-Jetty :: blahblah</name>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<verbose>false</verbose>
</configuration>
</plugin>
<!-- Convert the compiled classes into a clases.dex.
-->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>generate-dex</id>
<phase>process-classes</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<!-- executable>${env.ANDROID_HOME}/platform-tools/dx</executable
-->
<executable>java</executable>
<arguments>
<!-- <argument>-JXmx1024M</argument>
-->
<argument>-jar</argument>
<argument>${env.ANDROID_HOME}/platform-tools/lib/dx.jar</argument>
<argument>--dex</argument>
<argument>--verbose</argument>
<argument>--core-library</argument>
<argument>--output=${project.build.directory}/classes.dex</argument>
<argument>--positions=lines</argument>
<argument>${project.build.directory}/classes/</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copydex</id>
<phase>process-classes</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}/${project.artifactId}-${project.version}/WEB- INF/lib" />
<jar basedir="${project.build.directory}" update="true" includes="classes.dex" destfile="${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib/classes.zip" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${android.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>repo</id>
<releases>
<enabled>true</enabled>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>file://${project.basedir}/repo</url>
</repository>
</repositories>
</project>