Skip to content

Commit

Permalink
Setup Config Server
Browse files Browse the repository at this point in the history
  • Loading branch information
dksifoua committed Sep 26, 2024
1 parent f5bef19 commit 1b70d8f
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 43 deletions.
1 change: 1 addition & 0 deletions api-gateway/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {

implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
Expand Down
26 changes: 2 additions & 24 deletions api-gateway/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
server:
port: 8080

eureka:
client:
service-url:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}

spring:
application:
name: api-gateway
devtools:
livereload:
port: 35730

cloud:
gateway:
routes:
- id: catalog-service
uri: http://localhost:8081
predicates:
- Path=/api/v1/catalog/**
logging:
level:
root: info
org.springframework.cloud.gateway: trace
org.springframework.web: debug
org.springframework.web.reactive: debug
config:
import: optional:configserver:http://dksifoua:dksifoua@localhost:8888
1 change: 1 addition & 0 deletions catalog-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
developmentOnly 'org.springframework.boot:spring-boot-docker-compose'
Expand Down
21 changes: 2 additions & 19 deletions catalog-service/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
app:
base-path: /api/v1/catalog

eureka:
client:
service-url:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}

server:
port: 8081

spring:
application:
name: catalog-service
devtools:
livereload:
port: 35729

logging:
level:
root: info
org.springframework.web: debug
org.springframework.web.reactive: debug
config:
import: optional:configserver:http://dksifoua:dksifoua@localhost:8888
37 changes: 37 additions & 0 deletions config-server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
41 changes: 41 additions & 0 deletions config-server/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.4'
id 'io.spring.dependency-management' version '1.1.6'
}

group = 'io.dksifoua.eshop'
version = '0.0.1-SNAPSHOT'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

repositories {
mavenCentral()
}

ext {
set('springCloudVersion', "2023.0.3")
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.cloud:spring-cloud-config-server'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}

tasks.named('test') {
useJUnitPlatform()
}
1 change: 1 addition & 0 deletions config-server/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'config'
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.dksifoua.eshop.config;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;

@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {

public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}

}
27 changes: 27 additions & 0 deletions config-server/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
eureka:
client:
service-url:
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}

logging:
level:
root: info
org.springframework.cloud.config: debug

server:
port: 8888

spring:
application:
name: config-server

cloud:
config:
server:
git:
uri: https://github.com/dksifoua/eshop-config

security:
user:
name: dksifoua
password: dksifoua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.dksifoua.eshop.config;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
class ConfigServerApplicationTests {

@Test
void contextLoads() {
}

}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ rootProject.name = 'eshop'

include('api-gateway')
include('catalog-service')
include('config-server')
include('eureka-server')

0 comments on commit 1b70d8f

Please sign in to comment.