Created
March 22, 2020 14:52
-
-
Save asvignesh/633025984041ff7748181a9a935f7bad to your computer and use it in GitHub Desktop.
Spring Boot Config Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring.cloud.config.uri=http://localhost:7777 | |
spring.application.name=test | |
spring.profiles.active=dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id 'org.springframework.boot' version '2.2.5.RELEASE' | |
id 'io.spring.dependency-management' version '1.0.9.RELEASE' | |
id 'java' | |
} | |
group 'io.cloud-odo' | |
version '1.0-SNAPSHOT' | |
sourceCompatibility = 1.8 | |
repositories { | |
mavenCentral() | |
} | |
ext { | |
set('springCloudVersion', "Hoxton.SR3") | |
} | |
dependencies { | |
implementation 'org.springframework.cloud:spring-cloud-starter-config' | |
testImplementation('org.springframework.boot:spring-boot-starter-test') { | |
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' | |
} | |
} | |
dependencyManagement { | |
imports { | |
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" | |
} | |
} | |
test { | |
useJUnitPlatform() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.annotation.PostConstruct; | |
import org.springframework.beans.factory.annotation.Value; | |
import org.springframework.stereotype.Component; | |
@Component | |
public class ClientBean { | |
@Value("${k1}") | |
private String k1; | |
public String getK1() { | |
return k1; | |
} | |
@PostConstruct | |
public void postConstruct() { | |
System.out.println(k1); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
@SpringBootApplication | |
public class ConfigClientApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(ConfigClientApplication.class, args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment