diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..4cabe5b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,23 @@ +{ + "configurations": [ + { + "type": "java", + "name": "UserServiceApiApplication (DEV DEBUG)", + "request": "launch", + "mainClass": "br.com.rayankonecny.userserviceapi.UserServiceApiApplication", + "projectName": "user-service-api", + }, + { + "type": "java", + "name": "ConfigServerApplication", + "request": "launch", + "mainClass": "br.com.rayankonecny.configserver.ConfigServerApplication", + "projectName": "config-server", + "env": { + "CONFIG_SERVER_URI": "https://forgeo-olymp.duckdns.org/rayankonecny/config-server.git", + "CONFIG_SERVER_USERNAME": "rayankonecny", + "CONFIG_SERVER_PASSWORD": "550919ca9d3411b0611d697f6acb6744e4510000", + } + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 26f58ef..27f9555 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,4 +2,5 @@ "java.compile.nullAnalysis.mode": "disabled", "java.debug.settings.onBuildFailureProceed": true, "java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx4G -Xms100m -Xlog:disable" + } diff --git a/auth-service-api/gradle/plugins/dependencies.gradle b/auth-service-api/gradle/plugins/dependencies.gradle index 7cd0dff..4efdffa 100644 --- a/auth-service-api/gradle/plugins/dependencies.gradle +++ b/auth-service-api/gradle/plugins/dependencies.gradle @@ -25,6 +25,10 @@ dependencies { because('Starter para validação de dados') } + implementation ('org.springframework.cloud:spring-cloud-starter-config') { + because('Starter para configuracao de ambiente') + } + // Biblioteca de codigo comum implementation ('br.com.rayankonecny:hd-commons-lib:1.0.0') { because('Lib para compartilhar código comum entre os projetos') @@ -32,7 +36,7 @@ dependencies { // Spring Security implementation ('org.springframework.boot:spring-boot-starter-security') { - because('Starter para integrar com o Srping Security') + because('Starter para integrar com o Spring Security') } // Json Web Token diff --git a/auth-service-api/src/main/resources/application.yml b/auth-service-api/src/main/resources/application.yml index cae4a6f..4c5a6de 100644 --- a/auth-service-api/src/main/resources/application.yml +++ b/auth-service-api/src/main/resources/application.yml @@ -1,12 +1,21 @@ spring: application: - name: "auth-service-api" - data: - mongodb: - uri: mongodb://175.15.15.6:27017/olympdb - auto-index-creation: true - aot: - enabled: false -jwt.secret: "IHf3Yua/byvtA+iIcGWmkrLvpKEXTb5ClkXaZ0VDmYbr/6b1otCs38x68bidvZLAOB7anUtVQlCid6YDULO5XA==" -jwt.expiration: 120000 -jwt.expiration-sec.refresh-token: 3600 + name: auth-service-api + + config: + import: optional:configserver:http://localhost:8888 + +logging: + level: + org.springframework.cloud.config: DEBUG + org.springframework.boot.context.config: DEBUG + +# data: +# mongodb: +# uri: mongodb://175.15.15.6:27017/olympdb +# auto-index-creation: true +# aot: +# enabled: false +# jwt.secret: "IHf3Yua/byvtA+iIcGWmkrLvpKEXTb5ClkXaZ0VDmYbr/6b1otCs38x68bidvZLAOB7anUtVQlCid6YDULO5XA==" +# jwt.expiration: 120000 +# jwt.expiration-sec.refresh-token: 3600 diff --git a/config-server/.env b/config-server/.env index 56220dc..e69de29 100644 --- a/config-server/.env +++ b/config-server/.env @@ -1,3 +0,0 @@ -CONFIG_SERVER_URI=https://forgeo-olymp.duckdns.org/rayankonecny/config-server -CONFIG_SERVER_USERNAME=rayankonecny -CONFIG_SERVER_PASSWORD=550919ca9d3411b0611d697f6acb6744e4510000 \ No newline at end of file diff --git a/config-server/config-server b/config-server/config-server new file mode 160000 index 0000000..2bfd3ae --- /dev/null +++ b/config-server/config-server @@ -0,0 +1 @@ +Subproject commit 2bfd3aed95fcc335d32112c5132d58c8459acaed diff --git a/config-server/gradle/plugins/dependencies.gradle b/config-server/gradle/plugins/dependencies.gradle index e999d03..4bb9fcf 100644 --- a/config-server/gradle/plugins/dependencies.gradle +++ b/config-server/gradle/plugins/dependencies.gradle @@ -13,12 +13,6 @@ ext { } dependencies { - - // Spring Boot Starters initial project - implementation 'org.springframework.boot:spring-boot-starter' - implementation 'org.springframework.boot:spring-boot-starter-web' - - implementation 'org.springframework.cloud:spring-cloud-config-server' developmentOnly 'org.springframework.boot:spring-boot-devtools' testImplementation 'org.springframework.boot:spring-boot-starter-test' diff --git a/config-server/src/main/java/br/com/rayankonecny/configserver/ConfigServerApplication.java b/config-server/src/main/java/br/com/rayankonecny/configserver/ConfigServerApplication.java index 973fc2e..7de3a3d 100644 --- a/config-server/src/main/java/br/com/rayankonecny/configserver/ConfigServerApplication.java +++ b/config-server/src/main/java/br/com/rayankonecny/configserver/ConfigServerApplication.java @@ -4,6 +4,8 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.config.server.EnableConfigServer; +import jakarta.annotation.PostConstruct; + @EnableConfigServer @SpringBootApplication public class ConfigServerApplication { @@ -11,5 +13,11 @@ public class ConfigServerApplication { public static void main(String[] args) { SpringApplication.run(ConfigServerApplication.class, args); } - + + @PostConstruct + public void debugEnv() { + System.out.println(System.getenv("CONFIG_SERVER_URI")); + System.out.println(System.getenv("CONFIG_SERVER_USERNAME")); + System.out.println(System.getenv("CONFIG_SERVER_PASSWORD")); + } } diff --git a/config-server/src/main/resources/application.yml b/config-server/src/main/resources/application.yml index f9d9d15..839944a 100644 --- a/config-server/src/main/resources/application.yml +++ b/config-server/src/main/resources/application.yml @@ -1,13 +1,21 @@ spring: application: - name: 'config-server' + name: config-server + # profiles: + # active: dev cloud: config: server: git: - default-label: main uri: ${CONFIG_SERVER_URI} username: ${CONFIG_SERVER_USERNAME} password: ${CONFIG_SERVER_PASSWORD} + clone-on-start: true + default-label: main + server: - port: ${PORT:8888} \ No newline at end of file + port: ${PORT:8888} + +logging: + level: + org.springframework.cloud.config.server.environment: DEBUG diff --git a/user-service-api/gradle/wrapper/plugins/dependencies.gradle b/user-service-api/gradle/wrapper/plugins/dependencies.gradle index fa531ad..51a1ad8 100644 --- a/user-service-api/gradle/wrapper/plugins/dependencies.gradle +++ b/user-service-api/gradle/wrapper/plugins/dependencies.gradle @@ -21,7 +21,8 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'org.springframework.cloud:spring-cloud-starter-config' - implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap' + // implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap' + // Swagger / OpenAPI (compatível com Spring Boot 3.3.x) implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0' @@ -30,7 +31,7 @@ dependencies { compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok-mapstruct-binding:0.2.0' - + // Lombok para TESTES (ESSENCIAL) testCompileOnly 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' diff --git a/user-service-api/src/main/java/br/com/rayankonecny/userserviceapi/UserServiceApiApplication.java b/user-service-api/src/main/java/br/com/rayankonecny/userserviceapi/UserServiceApiApplication.java index f14ee98..55ed0e3 100644 --- a/user-service-api/src/main/java/br/com/rayankonecny/userserviceapi/UserServiceApiApplication.java +++ b/user-service-api/src/main/java/br/com/rayankonecny/userserviceapi/UserServiceApiApplication.java @@ -3,9 +3,17 @@ package br.com.rayankonecny.userserviceapi; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import jakarta.annotation.PostConstruct; + @SpringBootApplication public class UserServiceApiApplication { + // public static void main(String[] args) { SpringApplication.run(UserServiceApiApplication.class, args); } + + @PostConstruct + public void debugMongo() { + System.out.println(System.getProperty("spring.data.mongodb.uri")); + } } diff --git a/user-service-api/src/main/resources/application.yml b/user-service-api/src/main/resources/application.yml index 0a1953e..2b55d90 100644 --- a/user-service-api/src/main/resources/application.yml +++ b/user-service-api/src/main/resources/application.yml @@ -1,5 +1,11 @@ spring: - profiles: - active: dev application: - name: 'user-service-api' + name: user-service-api + + config: + import: optional:configserver:http://localhost:8888 + +logging: + level: + org.springframework.cloud.config: DEBUG + org.springframework.boot.context.config: DEBUG \ No newline at end of file diff --git a/user-service-api/src/main/resources/application_backp.txt b/user-service-api/src/main/resources/application_backp.txt new file mode 100644 index 0000000..c592ba7 --- /dev/null +++ b/user-service-api/src/main/resources/application_backp.txt @@ -0,0 +1,3 @@ +spring: + config: + import: optional:configserver:http://localhost:8888 diff --git a/user-service-api/src/main/resources/bootstrap.txt b/user-service-api/src/main/resources/bootstrap.txt new file mode 100644 index 0000000..e2dc658 --- /dev/null +++ b/user-service-api/src/main/resources/bootstrap.txt @@ -0,0 +1,4 @@ +spring: + application: + name: user-service-api +