我正在尝试通过gcloud将Web应用程序部署到GCP App Engine。 此Web应用程序使用两个不同的数据库-一个数据库位于“ A” App Engine SQL下,另一个数据库位于“ B” App Engine SQL下。简单地说,它现在由差异实例运行。
在本地数据库中,应用程序可以很好地运行,但是当我尝试编译Java项目时,它显示以下错误。
基于谷歌搜索,我试图找出缺少的依赖项,并将其插入到pom.xml文件中,但是它根本无法正常工作。
如果我将其从application.properties
指向本地数据库,它就能很好地进行编译。 (做编译的目的是生成jar文件来部署我的项目。):
### *** Removed username/password and datasource url ***
## ==============================================================
## = Datasource (Admin)
## ==============================================================
#admin.datasource.url = jdbc:mysql://localhost:3306/
admin.datasource.url = jdbc:mysql://google/url here
admin.datasource.username =
admin.datasource.password =
admin.datasource.driver-class-name=com.mysql.jdbc.Driver
## ==============================================================
## = Datasource 2 (API)
## ==============================================================
#api.datasource.url = jdbc:mysql://localhost:3306/
api.datasource.url = jdbc:mysql://google/url here
api.datasource.username =
api.datasource.password =
api.datasource.driver-class-name=com.mysql.jdbc.Driver
server.session.timeout = 600
spring.session.store-type=jdbc
server.port =8080
#server.error.whitelabel.enabled=false
我做mvn clean install
时出错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project WorkspezAdmin: There are test failures.
[ERROR]
[ERROR] Please refer to D:\admin_Deploy\target\surefire-reports for the individual test results.
如果我执行mvn clean and install
,则需要获取jar文件,该文件可以使用gcloud部署到GCP App Engine。有没有人可以给我相关建议?
谢谢您。
附加错误
The Google Cloud SQL API is not enabled for project [workspez-admin]. Please use the Google Developers Console to enable it: https://console.cloud.google.com/apis/api/sqladmin/overview?project=workspez-admin
Error creating bean with name 'adminEntityManagerFactory' defined in class path resource [com/workspez/webconfig/AdminHibernateDbConfig.class]: Unsatisfied dependency expressed through method 'adminEntityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminDataSource' defined in class path resource [com/workspez/webconfig/AdminHibernateDbConfig.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceInitializer': Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLNonTransientConnectionException: **Could not create connection to database server.**