我有一个基于Gradle的多模块Google App Engine(GAE)项目,该项目最初来自https://github.com/GoogleCloudPlatform/appengine-modules-sample-java。
该项目具有App Engine的Cloud Endpoints,我将其迁移到 Cloud Endpoints Framework ("云端点版本2")。我跟着https://cloud.google.com/endpoints/docs/frameworks/java/required_files,这意味着我改变了这些:
的build.gradle
+ compile 'com.google.endpoints:endpoints-framework-auth:1.0.0-beta.10'
+ compile 'com.google.endpoints:endpoints-management-control-appengine:1.0.0-beta.10'
应用服务引擎-web.xml中
+ <env-variables>
+ <env-var name="ENDPOINTS_SERVICE_NAME" value="myproject.appspot.com" />
+ </env-variables>
的web.xml
+ <!-- Endpoints service config from service management -->
+ <filter>
+ <filter-name>endpoints-api-configuration</filter-name>
+ <filter-class>com.google.api.control.ServiceManagementConfigFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>endpoints-api-configuration</filter-name>
+ <servlet-name>api</servlet-name>
+ </filter-mapping>
+
+ <!-- Endpoints logging and monitoring -->
+ <filter>
+ <filter-name>endpoints-api-controller</filter-name>
+ <filter-class>com.google.api.control.extensions.appengine.GoogleAppEngineControlFilter</filter-class>
+ <init-param>
+ <param-name>endpoints.projectId</param-name>
+ <param-value>myproject</param-value>
+ </init-param>
+ <init-param>
+ <param-name>endpoints.serviceName</param-name>
+ <param-value>myproject.appspot.com</param-value>
+ </init-param>
+ </filter>
+ <filter-mapping>
+ <filter-name>endpoints-api-controller</filter-name>
+ <servlet-name>api</servlet-name>
+ </filter-mapping>
(我已完成https://cloud.google.com/appengine/docs/java/endpoints/migrating中的部分,我将不在此讨论)
但是在尝试使用&#34; gradle appengineRun&#34;
尝试运行它时遇到此错误 Oct 24, 2016 8:53:12 AM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties
INFO: Overwriting system property key 'java.util.logging.config.file', value '/Users/username/.gradle/appengine-sdk/appengine-java-sdk-1.9.42/config/sdk/logging.properties' with value 'WEB-INF/logging.properties' from '/Users/username/Documents/code/myproject/web/ear/build/exploded-app/default-1.0/WEB-INF/appengine-web.xml'
Oct 24, 2016 8:53:12 AM com.google.appengine.tools.development.DevAppServerImpl <init>
INFO: Ignoring application.xml context-root element, for details see https://developers.google.com/appengine/docs/java/modules/#config
com.google.appengine.tools.development.EnvironmentVariableChecker$IncorrectEnvironmentVariableException: One or more environment variables have been configured in appengine-web.xml that have missing or different values in your local environment. We recommend you use system properties instead, but if you are interacting with legacy code that requires specific environment variables to have specific values, please set these environment variables in your environment before running.
[Mismatch environmentVariableName=ENDPOINTS_SERVICE_NAME environmentVariableValue=null appEngineWebXmlValue=myproject.appspot.com appEngineWebXmlFile=/Users/username/Documents/code/myproject/web/ear/build/exploded-app/default-1.0/WEB-INF/appengine-web.xml]
at com.google.appengine.tools.development.EnvironmentVariableChecker.check(EnvironmentVariableChecker.java:75)
at com.google.appengine.tools.development.ApplicationConfigurationManager.checkEnvironmentVariables(ApplicationConfigurationManager.java:240)
at com.google.appengine.tools.development.ApplicationConfigurationManager.access$000(ApplicationConfigurationManager.java:32)
at com.google.appengine.tools.development.ApplicationConfigurationManager$EarModuleConfigurationHandle.checkEnvironmentVariables(ApplicationConfigurationManager.java:486)
at com.google.appengine.tools.development.JettyContainerService.connectContainer(JettyContainerService.java:213)
at com.google.appengine.tools.development.AbstractContainerService.createConnection(AbstractContainerService.java:269)
at com.google.appengine.tools.development.AbstractInstanceHolder.createConnection(AbstractInstanceHolder.java:37)
at com.google.appengine.tools.development.AbstractModule.createConnection(AbstractModule.java:73)
at com.google.appengine.tools.development.Modules.createConnections(Modules.java:99)
at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:239)
at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:45)
at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:217)
at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:215)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:215)
at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:277)
at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:225)
at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:216)
我该如何解决这个问题?
答案 0 :(得分:4)
我添加了一个环境变量:
key = ENDPOINTS_SERVICE_NAME
value = myproject.appspot.com
(here how to add an enviroment variable)
Here是解释此标记含义的Google文档:
可选。 appengine-web.xml文件可以定义环境变量 在应用程序运行时设置。
为避免与您的本地环境发生冲突,请 开发服务器不会基于此设置环境变量 文件,并要求本地环境具有这些变量 已设置为匹配值。