使用googleappengine和mysql启动spring

q7solyqu  于 2021-06-24  发布在  Mysql
关注(0)|答案(0)|浏览(223)

我正在使用SpringBoot和google应用程序引擎以及google云sql,使用mysql。。在本地,它工作得很好,但是在部署到googleappengine之后,该站点没有加载。我检查了谷歌的错误报告,我看到了这个例外。
请建议如何解决这个问题。
在my application.properties中

spring.jpa.database=MYSQL
    spring.datasource.url=jdbc:mysql://google/<<DB_NAME>>?socketFactory=com.google.cloud.sql.mysql.SocketFactory&cloudSqlInstance=<<Instance connection name>>
    spring.datasource.username=<<username>>
    spring.datasource.password=<<pwd>>
    spring.datasource.tomcat.max-wait=20000
    spring.datasource.tomcat.max-active=50
    spring.datasource.tomcat.max-idle=20
    spring.datasource.tomcat.min-idle=15

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.id.new_generator_mappings = false
spring.jpa.properties.hibernate.format_sql = true
spring.jpa.hibernate.ddl-auto=update

logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

例外情况:
org.springframework.beans.factory.beancreationexception:创建名为“entitymanagerfactory”的bean时出错,该bean在类路径资源[org/springframework/boot/autoconfigure/orm/jpa/hibernatejpaconfiguration.class]中定义:调用init方法失败;嵌套的异常为javax.persistence.persistenceexception:[persistenceunit:default]无法在org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory)上构建hibernate sessionfactory。java:1710)在org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory)。java:583)位于org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory)。java:502)在org.springframework.beans.factory.support.abstractbeanfactory.lambda$dogetbean$0(abstractbeanfactory)。java:312)位于org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry)。java:228)位于org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.com)。java:310)在org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory)。java:200)位于org.springframework.context.support.abstractapplicationcontext.getbean(abstractapplicationcontext)。java:1085)位于org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext)。java:858)在org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext。java:549)在org.springframework.boot.web.servlet.context.servletwebserverapplicationcontext.refresh(servletwebserverapplicationcontext。java:140)在org.springframework.boot.springapplication.refresh(springapplication。java:752)在org.springframework.boot.springapplication.refreshcontext(springapplication。java:388)在org.springframework.boot.springapplication.run(springapplication。java:327)在org.springframework.boot.web.servlet.support.springbootservletinitializer.run(springbootservletinitializer。java:155)在org.springframework.boot.web.servlet.support.springbootservletinitializer.createrootapplicationcontext(springbootservletinitializer)。java:135)在org.springframework.boot.web.servlet.support.springbootservletinitializer.onstartup(springbootservletinitializer。java:87)在org.springframework.web.springservletcontainerinitializer.onstartup(springservletcontainerinitializer)。java:172)在org.eclipse.jetty.plus.annotation.containerinInitializer.callstartup(containerinInitializer。java:140)位于org.eclipse.jetty.annotations.servletcontainerinitializersstarter.dostart(servletcontainerinitializersstarter)。java:63)在org.eclipse.jetty.util.component.abstractlifecycle.start(抽象生命周期)。java:68)位于org.eclipse.jetty.servlet.servletcontexthandler.startcontext(servletcontexthandler。java:330)在org.eclipse.jetty.webapp.webappcontext.startwebapp(webappcontext。java:1406)在org.eclipse.jetty.webapp.webappcontext.startcontext(webappcontext。java:1368)在org.eclipse.jetty.server.handler.contexthandler.dostart(contexthandler。java:778)位于org.eclipse.jetty.servlet.servletcontexthandler.dostart(servletcontexthandler。java:262)在org.eclipse.jetty.webapp.webappcontext.dostart(webappcontext。java:522)在org.eclipse.jetty.util.component.abstractlifecycle.start(abstractlifecycle.org.eclipse.jetty.util.component.abstractlifecycle.start)上。java:68)在com.google.apphosting.runtime.jetty9.appversionhandlermap.createhandler(appversionhandlermap。java:244)在com.google.apphosting.runtime.jetty9.appversionhandlermap.gethandler(appversionhandlermap。java:182)在com.google.apphosting.runtime.jetty9.jettyservletengineadapter.servicerequest(jettyservletengineadapter。java:97)在com.google.apphosting.runtime.javaruntime$requestrunnable.dispatchservletrequest(javaruntime)。java:680)在com.google.apphosting.runtime.javaruntime$requestrunnable.dispatchrequest(javaruntime。java:642)在com.google.apphosting.runtime.javaruntime$requestrunnable.run(javaruntime。java:612)在com.google.apphosting.runtime.javaruntime$nullsandboxrequestrunnable.run(javaruntime。java:806)在com.google.apphosting.runtime.threadgrouppool$poolentry.run(threadgrouppool。java:274)在java.lang.thread.run(线程。java:745)原因:javax.persistence.persistenceexception:[persistenceunit:default]无法在上构建hibernate sessionfactoryorg.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl.persistenceexception(entitymanagerfactorybuilderimpl。java:970)在org.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl.build(entitymanagerfactorybuilderimpl。java:895)在org.springframework.orm.jpa.vendor.springhibernatejpapersistenceprovider.createContainerEntityManager工厂(springhibernatejpapersistenceprovider)。java:57)位于org.springframework.orm.jpa.localcontainerentitymanagerfactorybean.createnativeentitymanagerfactory(localcontainerentitymanagerfactorybean)。java:365)在org.springframework.orm.jpa.abstractentitymanagerfactorybean.buildnativeentitymanagerfactory(abstractentitymanagerfactorybean)。java:388)位于org.springframework.orm.jpa.abstractentitymanagerfactorybean.afterpropertiesset(abstractentitymanagerfactorybean)。java:377)在org.springframework.orm.jpa.localcontainerentitymanagerfactorbean.afterpropertiesset(localcontainerentitymanagerfactorbean)。java:341)位于org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.invokeinitmethods(abstractautowirecapablebeanfactory)。java:1769)在org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.initializebean(abstractautowirecapablebeanfactory)。java:1706) ... 36更多原因:org.hibernate.exception.jdbcconnectionexception:无法打开jdbc连接以在org.hibernate.exception.internal.sqlexceptiontypedelegate.convert(sqlexceptiontypedelegate)执行ddl。java:48)位于org.hibernate.exception.internal.standardsqlexceptionconverter.convert(standardsqlexceptionconverter。java:42)在org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper)。java:111)位于org.hibernate.engine.jdbc.spi.sqlexceptionhelper.convert(sqlexceptionhelper)。java:97)位于org.hibernate.resource.transaction.backend.jdbc.internal.ddltransactionisolatornonjtaimpl.getisolatedconnection(ddltransactionisolatornonjtaimpl)。java:69)在org.hibernate.tool.schema.internal.exec.improvedextractioncontextimpl.getjdbcconnection(improvedextractioncontextimpl。java:60)在org.hibernate.tool.schema.internal.exec.improvedextractioncontextimpl.getjdbcdatabasemetadata(improvedextractioncontextimpl。java:67)在org.hibernate.tool.schema.extract.internal.informationextractorjdbcdatabasemetadataimpl.gettables(informationextractorjdbcdatabasemetadataimpl。java:329)在org.hibernate.tool.schema.extract.internal.databaseinformationimpl.gettablesinformation(databaseinformationimpl。java:120)在org.hibernate.tool.schema.internal.groupedschemamigratorimpl.performtablesmigration(groupedschemamigratorimpl。java:65)在org.hibernate.tool.schema.internal.abstractschemamigrator.performmigration(abstractschemamigrator。java:207)位于org.hibernate.tool.schema.internal.abstractschemamigrator.domigration(abstractschemamigrator.com)。java:114)在org.hibernate.tool.schema.spi.schemamanagementtoolcoordinator.performdatabaseaction(schemamanagementtoolcoordinator)。java:183)在org.hibernate.tool.schema.spi.schemamanagementtoolcoordinator.process(schemamanagementtoolcoordinator。java:72)在org.hibernate.internal.sessionfactoryimpl。java:312)在org.hibernate.boot.internal.sessionfactorybuilderimpl.build(sessionfactorybuilderimpl。java:460)在org.hibernate.jpa.boot.internal.entitymanagerfactorybuilderimpl.build(entitymanagerfactorybuilderimpl。java:892) ... 43其他原因:com.mysql.jdbc.exceptions.jdbc4.mysqlnontransientconnectionexception:无法创建到数据库服务器的连接。在sun.reflect.nativeconstructoraccessorimpl.newinstance0(本机方法)在sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl)。java:62)在sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl。java:45)在java.lang.reflect.constructor.newinstance(constructor。java:423)在com.mysql.jdbc.util.handlenewinstance(util。java:411)在com.mysql.jdbc.util.getinstance(util。java:386)在com.mysql.jdbc.sqlerror.createsqlexception(sqlerror。java:1014)在com.mysql.jdbc.sqlerror.createsqlexception(sqlerror。java:988)在com.mysql.jdbc.sqlerror.createsqlexception(sqlerror。java:974)在com.mysql.jdbc.sqlerror.createsqlexception(sqlerror。java:919)在com.mysql.jdbc.connectionimpl.connectonetryonly(connectionimpl。java:2492)在com.mysql.jdbc.connectionimpl.createnewio(connectionimpl。java:2235)在com.mysql.jdbc.connectionimpl。java:818)在com.mysql.jdbc.jdbc4connection.(jdbc4connection。java:46)在sun.reflect.nativeconstructoraccessorimpl.newinstance0(本机方法)位于sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl)。java:62)在sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl。java:45)在java.lang.reflect.constructor.newinstance(constructor。java:423)在com.mysql.jdbc.util.handlenewinstance(util。java:411)在com.mysql.jdbc.connectionimpl.getinstance(connectionimpl。java:404)在com.mysql.jdbc.nonregisteringdriver.connect(nonregisteringdriver。java:307)在com.zaxxer.hikari.util.driverdatasource.getconnection(driverdatasource。java:117)在com.zaxxer.hikari.util.driverdatasource.getconnection(驱动数据源)。java:123)在com.zaxxer.hikari.pool.poolbase.newconnection(poolbase。java:365)在com.zaxxer.hikari.pool.poolbase.newpoolentry(poolbase。java:194)在com.zaxxer.hikari.pool.hikaripool.createpoolentry(hikaripool。java:460)在com.zaxxer.hikari.pool.hikaripool.checkfailfast(hikaripool。java:534)在com.zaxxer.hikari.pool.hikaripool。java:115)在com。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题