当我部署具有多个服务的应用程序时,尽管遵循 Configuration files overview 中描述的目录层次结构,但我看不到要在 App Engine 控制台中注册的 cron 作业。 .
这是我的 cron.xml
文件,我将其放置在默认服务的 WEB-INF
目录中:
<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
<cron>
<url>/cron</url>
<description>Execute scheduled tasks</description>
<schedule>every 5 minutes</schedule>
</cron>
</cronentries>
这是我的默认服务的 appengine-web.xml
文件:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>default</application>
<version>1</version>
<threadsafe>true</threadsafe>
<sessions-enabled>true</sessions-enabled>
<manual-scaling>
<instances>1</instances>
</manual-scaling>
</appengine-web-app>
我的 GAE 应用程序有 4 个服务,全部在 application.xml
文件中定义。
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
<display-name>modules-ear</display-name>
<module>
<web>
<web-uri>module-default-1.0</web-uri>
<context-root>module-default</context-root>
</web>
</module>
<module>
<web>
<web-uri>module-1-1.0</web-uri>
<context-root>module-1</context-root>
</web>
</module>
<!-- declared other modules likewise -->
<library-directory>lib</library-directory>
</application>
我的项目结构:
你能告诉我我做错了什么导致我的 cron 作业没有运行吗?
最佳答案
尝试在单独的命令中部署 cron 配置:
- 如果您使用gcloud cli :
gcloud应用程序部署cron.yaml
- 或者gradle appengine plugin :
./gradlew appengineUpdateCron
- 或者maven appengine plugin :
mvn appengine:update_cron
我遇到了同样的问题,部署后运行命令解决了它!
关于java - 无法在具有多个服务的 Google App Engine 应用程序中创建 cron 作业,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41794627/