diff --git a/.gitignore b/.gitignore index 3b191483..990eb61c 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ out/ **/resources/.env **/resources/.env.* +!**/resources/.env.example diff --git a/build.gradle.kts b/build.gradle.kts index 8ba79165..88856e5e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,6 +20,23 @@ repositories { dependencies { implementation("org.springframework.boot:spring-boot-starter") + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.springframework.boot:spring-boot-starter-data-jpa") + implementation("org.springframework.boot:spring-boot-starter-validation") + implementation("org.postgresql:postgresql:42.7.3") + implementation("me.paulschwarz:spring-dotenv:4.0.0") + + // Lombok + annotationProcessor("org.projectlombok:lombok:1.18.34") + testCompileOnly("org.projectlombok:lombok:1.18.34") + testAnnotationProcessor("org.projectlombok:lombok:1.18.34") + + // testcontainers + testImplementation("org.testcontainers:testcontainers:1.20.0") + testImplementation("org.testcontainers:junit-jupiter:1.20.0") + testImplementation("org.testcontainers:jdbc:1.20.0") + testImplementation("org.testcontainers:postgresql:1.20.0") + testImplementation("org.springframework.boot:spring-boot-starter-test") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/src/main/resources/.env.example b/src/main/resources/.env.example new file mode 100644 index 00000000..c3ff71d6 --- /dev/null +++ b/src/main/resources/.env.example @@ -0,0 +1,5 @@ +DATABASE_HOST= +DATABASE_PORT= +DATABASE_NAME= +DATABASE_USER= +DATABASE_PASSWORD= diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 22ca8c47..00000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -spring.application.name= run-us diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 00000000..9d053821 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,25 @@ +spring.application.name: run-us + +spring: + jpa: + hibernate: + ddl-auto: none + show-sql: true + open-in-view: false + + datasource: + driver-class-name: org.postgresql.Driver + url: jdbc:postgresql://${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME} + username: ${DATABASE_USER} + password: ${DATABASE_PASSWORD} + +--- +spring.config.activate.on-profile: local + +spring: + jpa: + hibernate: + ddl-auto: update + +--- +spring.config.activate.on-profile: prod diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml new file mode 100644 index 00000000..0ff7be5a --- /dev/null +++ b/src/test/resources/application.yml @@ -0,0 +1,11 @@ +spring: + jpa: + hibernate: + ddl-auto: create + show-sql: true + open-in-view: false + defer-datasource-initialization: true + + datasource: + driver-class-name: org.testcontainers.jdbc.ContainerDatabaseDriver + url: jdbc:tc:postgresql:16.3://test