[英]Deploying and Connecting cloud foundry service (MongoDB, Java, Spring Boot)
How to connect cloud foundry services to a spring boot maven project? 如何将Cloud Foundry服务连接到Spring Boot Maven项目? I thought putting spring.data.mongodb.uri = uri
to the property file will solve the problem. 我认为将spring.data.mongodb.uri = uri
放入属性文件将解决此问题。 Is there additional step to connect to the services created in cloud foundry? 是否有其他步骤可以连接到在Cloud Foundry中创建的服务? Thanks. 谢谢。 btw i add service using sts by checking the service in the deploying step. 顺便说一句,我通过在部署步骤中检查服务来使用sts添加服务。
@Bean
public MongoDbFactory mongoDbFactory() {
CloudEnvironment cloudEnvironment = new CloudEnvironment();
MongoServiceInfo serviceInfo = cloudEnvironment.getServiceInfo("servicename", MongoServiceInfo.class);
MongoServiceCreator serviceCreator = new MongoServiceCreator();
return serviceCreator.createService(serviceInfo);
}
so i add this code but it still hangs in the deployment. 所以我添加了这段代码,但是它仍然挂在部署中。 Is the service name is the service instance name? 服务名称是服务实例名称吗?
In order to connect cloud foundry services, you have to extend AbstractCloudConfig
class in Spring Boot App by using @Configuration
annotation. 为了连接云铸造服务,您必须使用@Configuration
注释在Spring Boot App中扩展AbstractCloudConfig
类。 I recommend you to read https://docs.cloudfoundry.org/buildpacks/java/configuring-service-connections/spring-service-bindings.html#javaconfig 我建议您阅读https://docs.cloudfoundry.org/buildpacks/java/configuring-service-connections/spring-service-bindings.html#javaconfig
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.