feature: client server implementation with spring cloud config
This commit is contained in:
parent
b85a3f2c3a
commit
07f47187f6
9
Makefile
9
Makefile
@ -11,3 +11,12 @@ test:
|
|||||||
|
|
||||||
run-client:
|
run-client:
|
||||||
$(GRADLE_BIN) client:bootRun
|
$(GRADLE_BIN) client:bootRun
|
||||||
|
|
||||||
|
run-server:
|
||||||
|
$(GRADLE_BIN) server:bootRun
|
||||||
|
|
||||||
|
curl-server:
|
||||||
|
curl -s -u "user:b3956c50-2e1e-4426-aaca-6b09f7cc4808" localhost:8090/client/development |jq
|
||||||
|
|
||||||
|
curl-client:
|
||||||
|
curl -s localhost:8080/v1/message
|
||||||
|
33
build.gradle.kts
Normal file
33
build.gradle.kts
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
plugins {
|
||||||
|
java
|
||||||
|
id("org.springframework.boot") version "3.0.5" apply false
|
||||||
|
id("io.spring.dependency-management") version "1.1.0" apply false
|
||||||
|
}
|
||||||
|
|
||||||
|
extra["springCloudVersion"] = "2022.0.2"
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
apply(plugin = "java")
|
||||||
|
apply(plugin = "org.springframework.boot")
|
||||||
|
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(
|
||||||
|
platform("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
|
||||||
|
)
|
||||||
|
|
||||||
|
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||||
|
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
|
||||||
|
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.getByName<Test>("test") {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
|
apply(plugin = "io.spring.dependency-management")
|
||||||
|
}
|
@ -1,39 +1,10 @@
|
|||||||
plugins {
|
|
||||||
java
|
|
||||||
id("org.springframework.boot") version "3.0.5"
|
|
||||||
id("io.spring.dependency-management") version "1.1.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
group = "tk.antoine.roux"
|
group = "tk.antoine.roux"
|
||||||
version = "0.0.1-SNAPSHOT"
|
version = "0.0.1-SNAPSHOT"
|
||||||
java.sourceCompatibility = JavaVersion.VERSION_17
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
extra["springCloudVersion"] = "2022.0.2"
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation("org.springframework.cloud:spring-cloud-starter-config")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
implementation("org.springframework.boot:spring-boot-starter-actuator")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||||
implementation("org.springframework.cloud:spring-cloud-starter-config")
|
|
||||||
|
|
||||||
developmentOnly("org.springframework.boot:spring-boot-devtools")
|
developmentOnly("org.springframework.boot:spring-boot-devtools")
|
||||||
|
|
||||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
|
|
||||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencyManagement {
|
|
||||||
imports {
|
|
||||||
mavenBom(
|
|
||||||
"org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.getByName<Test>("test") {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package tk.antoine.roux.springcloudconfig.application;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/v1")
|
||||||
|
public class Endpoint {
|
||||||
|
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
public Endpoint(@Value("${application.message}") String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/message")
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1 +1,3 @@
|
|||||||
|
spring.application.name=client
|
||||||
|
spring.profiles.active=development
|
||||||
|
spring.config.import=configserver:http://user:b3956c50-2e1e-4426-aaca-6b09f7cc4808@localhost:8090
|
||||||
|
@ -1,29 +1,8 @@
|
|||||||
plugins {
|
|
||||||
java
|
|
||||||
id("org.springframework.boot") version "3.0.5"
|
|
||||||
id("io.spring.dependency-management") version "1.1.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
group = "tk.antoine.roux"
|
group = "tk.antoine.roux"
|
||||||
version = "0.0.1-SNAPSHOT"
|
version = "0.0.1-SNAPSHOT"
|
||||||
java.sourceCompatibility = JavaVersion.VERSION_17
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
extra["springCloudVersion"] = "2022.0.2"
|
|
||||||
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.springframework.cloud:spring-cloud-config-server")
|
implementation("org.springframework.cloud:spring-cloud-config-server")
|
||||||
implementation("org.springframework.cloud:spring-cloud-starter-config")
|
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||||
|
implementation("org.springframework.boot:spring-boot-starter-security")
|
||||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
|
||||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
|
|
||||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.getByName<Test>("test") {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
application.message=Hello world
|
@ -1,5 +1,9 @@
|
|||||||
package tk.antoine.roux.springcloudconfig;
|
package tk.antoine.roux.springcloudconfig;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.config.server.EnableConfigServer;
|
||||||
|
|
||||||
@EnableConfigServer
|
@EnableConfigServer
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class SpringCloudConfigServerApplication {
|
public class SpringCloudConfigServerApplication {
|
||||||
|
10
server/src/main/resources/application.properties
Normal file
10
server/src/main/resources/application.properties
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
server.port=8090
|
||||||
|
spring.profiles.active=native
|
||||||
|
spring.cloud.config.server.native.search-locations=file:./config-repo/{application}/{profile}
|
||||||
|
|
||||||
|
spring.security.user.name=user
|
||||||
|
spring.security.user.password=b3956c50-2e1e-4426-aaca-6b09f7cc4808
|
||||||
|
|
||||||
|
#spring.cloud.config.server.git.uri=file://${user.home}/config-repo
|
||||||
|
#spring.cloud.config.server.git.search-paths='{application}/{profile}'
|
||||||
|
#spring.cloud.config.server.git.refresh-rate=10
|
Loading…
Reference in New Issue
Block a user