我正在使用 Maven 遵循Java 中的 Google Cloud Endpoints入门指南,但我无法使用 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 目标会为我解决这个问题。