https://github.com/sandysanthosh/spring-cloud-config
Spring Boot application with Cloud Configuration using Spring Cloud Config
https://github.com/sandysanthosh/spring-cloud-config
boot spring
Last synced: 14 days ago
JSON representation
Spring Boot application with Cloud Configuration using Spring Cloud Config
- Host: GitHub
- URL: https://github.com/sandysanthosh/spring-cloud-config
- Owner: sandysanthosh
- Created: 2017-12-18T16:47:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-29T17:22:58.000Z (over 3 years ago)
- Last Synced: 2025-02-28T20:57:17.455Z (over 1 year ago)
- Topics: boot, spring
- Homepage: https://sandysanthosh.github.io/Pivotal-Cloud-Foundry/
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pivotal-Cloud-Foundry
How to Deploy Spring Boot Application to Cloud Foundry Platform
#### Technology Stack:
We will use below technology stack for the spring boot application development and testing.
* Spring Boot
* Spring REST
* Maven
* Eclipse
* Cloud Foundry CLI
* Web Browser
#### Spring Boot application with Cloud Configuration using Spring Cloud Config:
```
org.springframework.cloud
spring-cloud-config-client
```
#### Next, you will need to configure your application to connect to a Spring Cloud Config Server. You can do this by adding the following to your
#### application.properties or application.yml file:
```
spring.cloud.config.uri=http://localhost:8888
```
#### class MyConfig:
```
@Configuration
@RefreshScope
public class MyConfig {
@Value("${my.config.property}")
private String myConfigProperty;
public String getMyConfigProperty() {
return myConfigProperty;
}
}
```
#### Create a REST controller class to handle HTTP requests and inject the Configuration class:
```
@RestController
public class MyController {
@Autowired
private MyConfig myConfig;
@GetMapping("/config")
public String getConfig() {
return myConfig.getMyConfigProperty();
}
}
```
To deploy the application to the cloud, you can use a service like Heroku, AWS, or Google Cloud Platform. You will need to configure the necessary dependencies and settings for your chosen platform.
Finally, use Spring Cloud Config to externalize your application configuration, so that you can manage it in a central location, rather than hard-coding it in the application itself.
#### You will also need to set up a Spring Cloud Config Server. You can do this by creating a new Spring Boot application and adding the following dependency:
```
org.springframework.cloud
spring-cloud-config-server
```
#### application.properties or application.yml file:
```
spring.cloud.config.server.git.uri=file:///${user.home}/config-repo
```
Create a git repository to store the configuration files and push the files to the remote repository.
Now, when the application starts, it will connect to the Spring Cloud Config Server and retrieve the configuration properties