【发布时间】:2013-11-14 14:54:16
【问题描述】:
我正在使用 Maven 关注 Getting Started guide for Google Cloud Endpoints in Java,但我无法使用 API Explorer 访问我的端点。
虽然我在我的项目中添加了一些结构,但我大部分时间都遵循了指南。我的根项目包是com.ryanharter.devinfo,我的端点位于com.ryanharter.devinfo.spi 包中,而我的模型类位于com.ryanharter.devinfo.beans 中(这是根据Mobile Backend Starter 建模的)。
我已经编写了 Endpoints 类并对其进行了注释:
@Api(name = "deviceinfo",
version = "v1",
namespace = @ApiNamespace(
ownerDomain = "ryanharter.com",
ownerName = "ryanharter.com",
packagePath = "devinfo")
)
public class DeviceInfoV1 {
@ApiMethod(name = "list", path = "devices", httpMethod = HttpMethod.GET)
public DeviceListDto list(QueryDto query) {
...
}
...
}
所有这些看起来都很好,并且与我拥有的其他工作项目相匹配,但是当我运行开发服务器时,我得到一个空白屏幕。
我还注意到我的 maven 日志显示了这一点:
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ devinfo ---
[INFO] Compiling 8 source files to /path/to/devinfo/target/classes
[INFO]
[INFO] --- appengine-maven-plugin:1.8.7:endpoints_get_discovery_doc (default) @ devinfo ---
[INFO]
[INFO] Google App Engine Java SDK - get endpoints discovery doc...
[INFO] No Endpoints classes detected.
我看到“未检测到端点类”。我还注意到/path/to/devinfo/target/classes 是空的。
据我所知,除了包结构和类内容之外,我还按照上面链接的指南进行操作。
编辑:
回应 Dan,这是我的 web.xml 文件的内容:
<?xml version="1.0" encoding="utf-8"?>
<web-app
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
</web-app>
根据上面链接的文档,我没有碰过这个。这正是 Maven 原型生成的内容。我在网上看到了需要在web.xml 中手动映射我的端点的报告,但是文档对此只字未提,所以我认为一个 maven 目标会为我解决这个问题。
【问题讨论】:
-
您能分享一下您的 web.xml 文件的内容吗?
-
感谢@DanHolevoet,我已编辑问题以包含 web.xml 文件的内容。
标签: java google-app-engine maven google-cloud-endpoints