[英]Binding Java application to MySQL in Cloud Foundry
I'm trying to bind MySQL service, which is in on prem cloud foundry, to my Java application. 我正在尝试将Prem Cloud Foundry中的MySQL服务绑定到我的Java应用程序。 could anyone suggest me what are the necessary changes to be made in my code to access MySQL database. 谁能建议我对访问MySQL数据库的代码进行哪些必要的更改。
If you are using Spring Boot, this should happen almost automatically as described in a Spring blog post . 如果您使用的是Spring Boot,这应该几乎自动执行, 如Spring博客文章中所述 。
If you are using Spring without Spring Boot, you may want to use Spring Cloud Connectors . 如果您使用的是不带 Spring Boot的Spring,则可能要使用Spring Cloud Connectors 。
If you are using neither, you can interrogate the VCAP_SERVICES environment variable for details of your service. 如果您都不使用它们,则可以查询VCAP_SERVICES环境变量以获取服务的详细信息。
On cloud foundry, you will have to provision a service for your app. 在Cloud Foundry上,您将必须为您的应用程序提供服务。
Look for available services. 寻找可用的服务。
cf marketplace cf市场
Identify the mysql service and the plan. 确定mysql服务和计划。 Create the service instance 创建服务实例
cf create-service p-mysql 512mb mysql cf创建服务p-mysql 512mb mysql
To see the service instances 查看服务实例
cf services cf服务
Bind the service instance to your app 将服务实例绑定到您的应用
cf bind-service myapp mysql cf绑定服务myapp mysql
You can see the details as 您可以看到的详细信息为
cf env myapp cf env myapp
EngineerBetter
has already provided you articles on how to use Spring to leverage the service in your app code. EngineerBetter
已经为您提供了有关如何使用Spring在您的应用程序代码中利用该服务的文章。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.