gpt4 book ai didi

java - Google Cloud Endpoints SPI 受限

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:28:56 26 4
gpt4 key购买 nike

我使用 Google Cloud Endpoints 定义了一个简单的 API:

@Api(name = "realestate", version = "v1")
public class RealEstatePropertyV1 {

@ApiMethod(name = "properties", httpMethod = "GET")
public List<RealEstateProperty> list() {
return ofy().load().type(RealEstateProperty.class).list();
}
}

我还配置了web.xml:

 <servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.realestate.api.v1.RealEstatePropertyV1</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>SystemServiceServlet</servlet-name>
<url-pattern>/_ah/spi/*</url-pattern>
</servlet-mapping>
</web-app>

我在 eclipse 中启动 API 并执行 curl http://localhost:8888/_ah/spi/realestate/v1/properties。响应是

<html><head><title>Error 405 HTTP method GET is not supported by this URL</title></head>
<body><h2>Error 405 HTTP method GET is not supported by this URL</h2></body>
</html>

服务器日志是:

Jun 20, 2013 9:22:14 PM com.google.appengine.tools.development.DevAppServerImpl start
INFO: Dev App Server is now running
Jun 20, 2013 9:22:29 PM com.google.api.server.spi.SystemServiceServlet init
INFO: SPI restricted: true

你知道SPI restricted是什么意思吗?我想提一下,我没有在 Google API 控制台中注册任何东西。我的目标是首先在本地测试 API。

最佳答案

要测试您的应用程序,请尝试

curl -X POST -d "{}" \
> -H "Content-Type: application/json" \
> http://localhost:8888/_ah/spi/realestate/v1/properties

更好的是,使用 API 资源管理器测试您的应用程序

http://localhost:8888/_ah/api/explorer

至于您日志中的SPI restricted,这只是表明该方法是否设置了身份验证。在您的情况下,对于此方法,它是 true

关于java - Google Cloud Endpoints SPI 受限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17222235/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com