From 818ee19b3b6bb770dc61f345224b5d860b795121 Mon Sep 17 00:00:00 2001 From: Branislav Beno Date: Sun, 10 Nov 2024 20:36:45 +0100 Subject: [PATCH] feat: Enable local development --- app/build.gradle.kts | 5 +++++ app/src/main/resources/application.yml | 12 ++++++++++++ ...tionaryLearningPlatformTestApplication.java | 15 +++++++++++++++ .../platform/config/ContainersConfig.java | 18 ++++++++++++++++++ gradle/libs.versions.toml | 1 + 5 files changed, 51 insertions(+) create mode 100644 app/src/test/java/com/dictionary/learning/platform/DictionaryLearningPlatformTestApplication.java create mode 100644 app/src/test/java/com/dictionary/learning/platform/config/ContainersConfig.java diff --git a/app/build.gradle.kts b/app/build.gradle.kts index bf49834..d78bc64 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,5 @@ +import org.springframework.boot.gradle.tasks.bundling.BootJar + plugins { java alias(libs.plugins.spring.boot) @@ -31,5 +33,8 @@ dependencies { testImplementation(libs.testcontainers.common) testImplementation(libs.testcontainers.junit.jupiter) testImplementation(libs.testcontainers.postgresql) + testCompileOnly(libs.spring.boot.devtools) testRuntimeOnly(libs.junit.platform.launcher) } + +tasks.getByName("bootJar") { this.archiveFileName.set("dictionary-learning-platform.jar") } diff --git a/app/src/main/resources/application.yml b/app/src/main/resources/application.yml index 0b215b0..479e9e4 100644 --- a/app/src/main/resources/application.yml +++ b/app/src/main/resources/application.yml @@ -9,6 +9,18 @@ spring: virtual: enabled: true +management: + endpoint: + health: + show-details: always + endpoints: + web: + exposure: + include: info,health,sbom +server: + error: + whitelabel: + enabled: false gg: jte: development-mode: true diff --git a/app/src/test/java/com/dictionary/learning/platform/DictionaryLearningPlatformTestApplication.java b/app/src/test/java/com/dictionary/learning/platform/DictionaryLearningPlatformTestApplication.java new file mode 100644 index 0000000..6448d03 --- /dev/null +++ b/app/src/test/java/com/dictionary/learning/platform/DictionaryLearningPlatformTestApplication.java @@ -0,0 +1,15 @@ +package com.dictionary.learning.platform; + +import com.dictionary.learning.platform.config.ContainersConfig; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DictionaryLearningPlatformTestApplication { + + public static void main(String[] args) { + SpringApplication.from(DictionaryLearningPlatformApplication::main) + .with(ContainersConfig.class) + .run(args); + } +} diff --git a/app/src/test/java/com/dictionary/learning/platform/config/ContainersConfig.java b/app/src/test/java/com/dictionary/learning/platform/config/ContainersConfig.java new file mode 100644 index 0000000..aa9482c --- /dev/null +++ b/app/src/test/java/com/dictionary/learning/platform/config/ContainersConfig.java @@ -0,0 +1,18 @@ +package com.dictionary.learning.platform.config; + +import org.springframework.boot.devtools.restart.RestartScope; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.testcontainers.service.connection.ServiceConnection; +import org.springframework.context.annotation.Bean; +import org.testcontainers.containers.PostgreSQLContainer; + +@TestConfiguration(proxyBeanMethods = false) +public class ContainersConfig { + + @Bean + @ServiceConnection + @RestartScope + public PostgreSQLContainer postgresSqlContainer() { + return new PostgreSQLContainer<>("postgres:16.4"); + } +} diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c141fa7..a5b0de4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,6 +7,7 @@ spring-boot-starter-actuator = { module = "org.springframework.boot:spring-boot- spring-boot-starter-data-jpa = { module = "org.springframework.boot:spring-boot-starter-data-jpa" } spring-boot-starter-validation = { module = "org.springframework.boot:spring-boot-starter-validation" } spring-boot-starter-test = { module = "org.springframework.boot:spring-boot-starter-test" } +spring-boot-devtools = { module = "org.springframework.boot:spring-boot-devtools" } spring-boot-testcontainers = { module = "org.springframework.boot:spring-boot-testcontainers" } junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher" } database-postgresql = { module = "org.postgresql:postgresql" }