google 端点的 503 服务不可用
503 Service Unavailable for google endpoints
我正在使用端点尝试为我的 Web 应用程序创建患者实体。当我尝试 运行 API.
时,我不断收到以下错误代码
503 Service Unavailable
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "java.lang.IllegalStateException: You have not started an Objectify context. You are probably missing the ObjectifyFilter. If you are not running in the context of an http request, see the ObjectifyService.run() method."
}
],
"code": 503,
"message": "java.lang.IllegalStateException: You have not started an Objectify context. You are probably missing the ObjectifyFilter. If you are not running in the context of an http request, see the ObjectifyService.run() method."
}
}
我知道这与静态 ofy 文件有关,但我不确定如何向其中添加过滤器。
这是我的静态对象化文件的代码。
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyService;
public class OfyService
{
public static Objectify ofy()
{
return ObjectifyService.ofy();
}
}
然后我在APIclass
中使用这个方法调用ofy文件
ofy().save().entity(patient).now();
将此代码添加到您的 web.xml
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
我正在使用端点尝试为我的 Web 应用程序创建患者实体。当我尝试 运行 API.
时,我不断收到以下错误代码 503 Service Unavailable
- Show headers -
{
"error": {
"errors": [
{
"domain": "global",
"reason": "backendError",
"message": "java.lang.IllegalStateException: You have not started an Objectify context. You are probably missing the ObjectifyFilter. If you are not running in the context of an http request, see the ObjectifyService.run() method."
}
],
"code": 503,
"message": "java.lang.IllegalStateException: You have not started an Objectify context. You are probably missing the ObjectifyFilter. If you are not running in the context of an http request, see the ObjectifyService.run() method."
}
}
我知道这与静态 ofy 文件有关,但我不确定如何向其中添加过滤器。 这是我的静态对象化文件的代码。
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyService;
public class OfyService
{
public static Objectify ofy()
{
return ObjectifyService.ofy();
}
}
然后我在APIclass
中使用这个方法调用ofy文件ofy().save().entity(patient).now();
将此代码添加到您的 web.xml
<filter>
<filter-name>ObjectifyFilter</filter-name>
<filter-class>com.googlecode.objectify.ObjectifyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ObjectifyFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>