spring.cloud.propertiesFile: ${user.home}/.config/myApp/spring-cloud.properties
+spring.cloud.propertiesFile: ${user.home}/.config/myApp/spring-cloud.properties
diff --git a/cloudfoundry-connector.html b/cloudfoundry-connector.html index dd657f6..c2a5091 100644 --- a/cloudfoundry-connector.html +++ b/cloudfoundry-connector.html @@ -408,6 +408,97 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b .hide-for-print{display:none!important} .show-for-print{display:inherit!important}} +
spring.cloud.propertiesFile: ${user.home}/.config/myApp/spring-cloud.properties
+spring.cloud.propertiesFile: ${user.home}/.config/myApp/spring-cloud.properties
spring.cloud.appId: myApp
+spring.cloud.appId: myApp
; spring.cloud.{id}: URI
spring.cloud.database: mysql://user:pass@host:1234/dbname
<!-- to use Spring Cloud Connectors for development -->
-<dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-localconfig-connector</artifactId>
- <version>1.1.1.RELEASE</version>
-</dependency>
+<!-- to use Spring Cloud Connectors for development -->
+<dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-localconfig-connector</artifactId>
+ <version>1.1.1.RELEASE</version>
+</dependency>
-<!-- If you intend to deploy the app to Cloud Foundry -->
-<dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-cloudfoundry-connector</artifactId>
- <version>1.1.1.RELEASE</version>
-</dependency>
+<!-- If you intend to deploy the app to Cloud Foundry -->
+<dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-cloudfoundry-connector</artifactId>
+ <version>1.1.1.RELEASE</version>
+</dependency>
-<!-- If you intend to deploy the app to Heroku -->
-<dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-heroku-connector</artifactId>
- <version>1.1.1.RELEASE</version>
-</dependency>
+<!-- If you intend to deploy the app to Heroku -->
+<dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-heroku-connector</artifactId>
+ <version>1.1.1.RELEASE</version>
+</dependency>
<dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-spring-service-connector</artifactId>
- <version>1.1.1.RELEASE</version>
-</dependency>
+<dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-spring-service-connector</artifactId>
+ <version>1.1.1.RELEASE</version>
+</dependency>
-<!-- to use Spring Cloud for development -->
-<dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-localconfig-connector</artifactId>
- <version>1.1.1.RELEASE</version>
-</dependency>
+<!-- to use Spring Cloud for development -->
+<dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-localconfig-connector</artifactId>
+ <version>1.1.1.RELEASE</version>
+</dependency>
-<!-- If you intend to deploy the app to Cloud Foundry -->
-<dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-cloudfoundry-connector</artifactId>
- <version>1.1.1.RELEASE</version>
-</dependency>
+<!-- If you intend to deploy the app to Cloud Foundry -->
+<dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-cloudfoundry-connector</artifactId>
+ <version>1.1.1.RELEASE</version>
+</dependency>
-<!-- If you intend to deploy the app to Heroku -->
-<dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-heroku-connector</artifactId>
- <version>1.1.1.RELEASE</version>
-</dependency>
+<!-- If you intend to deploy the app to Heroku -->
+<dependency>
+ <groupId>org.springframework.cloud</groupId>
+ <artifactId>spring-cloud-heroku-connector</artifactId>
+ <version>1.1.1.RELEASE</version>
+</dependency>
CloudFactory cloudFactory = new CloudFactory();
+CloudFactory cloudFactory = new CloudFactory();
Obtain the Cloud object for the environment in which the application is running.
Cloud cloud = cloudFactory.getCloud();
+Cloud cloud = cloudFactory.getCloud();
// ServiceInfo has all the information necessary to connect to the underlying service
-List<ServiceInfo> serviceInfos = cloud.getServiceInfos();
+// ServiceInfo has all the information necessary to connect to the underlying service
+List<ServiceInfo> serviceInfos = cloud.getServiceInfos();
// find the `ServiceInfo` definitions suitable for connecting to a particular service type
-List<ServiceInfo> databaseInfos = cloud.getServiceInfos(DataSource.class);
+// find the `ServiceInfo` definitions suitable for connecting to a particular service type
+List<ServiceInfo> databaseInfos = cloud.getServiceInfos(DataSource.class);
// Alternately, let Spring Cloud create a service connector for you
-String serviceId = "inventory-db";
-DataSource ds = cloud.getServiceConnector(serviceId, DataSource.class, null /* default config */);
+// Alternately, let Spring Cloud create a service connector for you
+String serviceId = "inventory-db";
+DataSource ds = cloud.getServiceConnector(serviceId, DataSource.class, null /* default config */);
public class HelloWorldServiceInfo extends UriBasedServiceInfo {
- public static final String URI_SCHEME = "helloworld";
+public class HelloWorldServiceInfo extends UriBasedServiceInfo {
+ public static final String URI_SCHEME = "helloworld";
- // needed to support structured service definitions like Cloud Foundry
- public HelloWorldServiceInfo(String id, String host, int port, String username, String password, String greeting) {
- super(id, URI_SCHEME, host, port, username, password, greeting);
+ // needed to support structured service definitions like Cloud Foundry
+ public HelloWorldServiceInfo(String id, String host, int port, String username, String password, String greeting) {
+ super(id, URI_SCHEME, host, port, username, password, greeting);
}
- // needed to support URI-based service definitions like Heroku
- public HelloWorldServiceInfo(String id, String uri) {
- super(id, uri);
+ // needed to support URI-based service definitions like Heroku
+ public HelloWorldServiceInfo(String id, String uri) {
+ super(id, uri);
}
}
class CloudConfig extends AbstractCloudConfig {
- @Bean
- public DataSource inventoryDataSource() {
- return connectionFactory().dataSource();
+class CloudConfig extends AbstractCloudConfig {
+ @Bean
+ public DataSource inventoryDataSource() {
+ return connectionFactory().dataSource();
}
- @Bean
- public MongoDbFactory documentMongoDbFactory() {
- return connectionFactory().mongoDbFactory();
+ @Bean
+ public MongoDbFactory documentMongoDbFactory() {
+ return connectionFactory().mongoDbFactory();
}
- //... more beans to obtain service connectors
+ //... more beans to obtain service connectors
}
class CloudConfig extends AbstractCloudConfig {
- @Bean
- public DataSource inventoryDataSource() {
- return connectionFactory().dataSource("inventory-db-service");
+class CloudConfig extends AbstractCloudConfig {
+ @Bean
+ public DataSource inventoryDataSource() {
+ return connectionFactory().dataSource("inventory-db-service");
}
- @Bean
- public MongoDbFactory documentMongoDbFactory() {
- return connectionFactory().mongoDbFactory("document-service");
+ @Bean
+ public MongoDbFactory documentMongoDbFactory() {
+ return connectionFactory().mongoDbFactory("document-service");
}
- //... more beans to obtain service connectors
+ //... more beans to obtain service connectors
}
@Configuration
-@ServiceScan
-class CloudConfig {
+@Configuration
+@ServiceScan
+class CloudConfig {
}
class CloudPropertiesConfig extends AbstractCloudConfig {
- @Bean
- public Properties cloudProperties() {
- return properties();
+class CloudPropertiesConfig extends AbstractCloudConfig {
+ @Bean
+ public Properties cloudProperties() {
+ return properties();
}
}