我正在尝试使用codebase来测试Google Cloud SQL实例与GAE应用程序的连接。我能够在本地成功运行它,但似乎它也在AppEngine中成功部署,但是当我尝试访问myproject.appspot.com时,我得到了404.
以下是我遵循的步骤(跳过成功的本地相关步骤)。
myproject
myproject-db
root
用户。"jdbc:google:mysql://myproject:us-central1:myproject-db/demo?user=root&password=PASSWORD;"
appengine-web.xml如下所示
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>myproject</application>
<version>1</version>
<threadsafe>true</threadsafe>
<use-google-connector-j>true</use-google-connector-j>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
<property name="cloudsql.url" value="jdbc:google:mysql://myproject:us-central1:myproject-db/demo?user=root&password=PASSWORD;"/>
<property name="cloudsql.url.dev" value="jdbc:mysql://localhost/demo?user=root&useSSL=false"/>
</system-properties>
</appengine-web-app>
以下代码片段嵌入在HibernateJPAServlet中
if (System.getProperty("com.google.appengine.runtime.version")
.startsWith("Google App Engine/")) {
Class.forName("com.mysql.jdbc.GoogleDriver");
properties.put("javax.persistence.jdbc.driver",
"com.mysql.jdbc.GoogleDriver");
properties.put("javax.persistence.jdbc.url",
System.getProperty("cloudsql.url"));
}
我已将代码从本地上传到默认的myproject存储库
我从“开发”视图启动了Google云端控制台。
mvn clean package
和mvn appengine:update
。由于防火墙/代理限制,我无法从本地执行appengine:update
。http://myproject.appspot.com/
应该托管我上传的应用程序第8步。但是当我访问它时,请"404" - "The requested URL / was not found on this server."
如果问题是我们无法从云控制台部署它,那么我还有其他选择吗?我绝对无法改变网络/代理规则。
我尝试使用mvn gcloud:run
和mvn gcloud:deploy
从代理/防火墙外部限制运行和部署应用程序。最后明确指出"Deployed URL: [https://myproject.appspot.com]"
。但是当我通过浏览器访问同一个Url时,同样的问题仍然存在。
我能够从App Engine仪表板中看到错误跟踪。这是说
" org.hibernate.exception.JDBCConnectionException: Could not open connection
Caused by: org.hibernate.exception.JDBCConnectionException: Could not open connection
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost."
我的连接字符串是“jdbc:google:mysql:// myproject:us-central1:myproject-db / demo?user = root&amp; password = PASSWD123&amp;”
答案 0 :(得分:0)
这是我的错(也是部分文档差距,我也给出了反馈)。每次我们通过appengine
或gcloud
部署应用时,都应通过"App Engine > Versions"
标签显示新部署的版本。我们应该"Split Traffic"
并将"100%"
(用于测试)提供给新部署的版本,然后启动&#34; https://myproject.appspot.com&#34;看到我们想要看到的结果。