我用Java创建了一个spring引导项目,它在我的本地数据库中工作得很好,但我无法将它连接到我的GCP postgres云SQL实例。
我遵循了以下步骤:https://cloud.spring.io/spring-cloud-gcp/multi/multi__spring_jdbc.html我还在pom.xml中做了所需的更改。在application.properties文件中有什么需要修改的地方吗?
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=none
spring.jpa.hibernate.show-sql=true
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.datasource.initialization-mode=always
spring.datasource.initialize=true
spring.datasource.schema=classpath:/schema.sql
spring.datasource.continue-on-error=true我希望我的项目能够正常工作,指向云数据库。
发布于 2019-05-22 17:08:55
取决于您使用的是哪种云。
您创建的数据库有一个终结点。
您必须放置端点链接,而不是Localhost.spring.datasource.url=jdbc:postgresql://(put your end point here instead of localhost):5432/postgres
确保您的数据库名称应与链接中的名称相同。
如果你使用的是Spring,那么你应该首先创建数据库开发环境。
除了在Pom.xml中,您需要添加对云的依赖。
如果你想访问数据库,那么你必须使用JackDB平台。
感谢和问候,
JerryRank
https://stackoverflow.com/questions/56252957
复制相似问题