From adee746b2315b9b7857fd72fe76051f5599a2afe Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 15 Mar 2026 12:21:16 +0100 Subject: [PATCH] refactor: migrate to YAML config and add Maven dev/prod profiles - Replace application.properties with application.yaml (base/prod config) and application-dev.yaml (dev overrides: show-sql=true) - Add Maven 'dev' profile (activeByDefault) and 'prod' profile to pom.xml; spring-boot:run picks up the active Spring profile automatically - Guard DataInitializer.initData with @Profile("dev") so test data is never seeded in production Local dev: ./mvnw spring-boot:run (dev profile active by default) Production: SPRING_PROFILES_ACTIVE env var controls the Spring profile; Maven profiles are irrelevant for the packaged JAR. Co-Authored-By: Claude Sonnet 4.6 --- backend/pom.xml | 23 ++++++++++ .../config/DataInitializer.java | 2 + .../src/main/resources/application-dev.yaml | 3 ++ .../src/main/resources/application.properties | 28 ------------- backend/src/main/resources/application.yaml | 42 +++++++++++++++++++ 5 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 backend/src/main/resources/application-dev.yaml delete mode 100644 backend/src/main/resources/application.properties create mode 100644 backend/src/main/resources/application.yaml diff --git a/backend/pom.xml b/backend/pom.xml index fe797f4d..74e95a2e 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -148,11 +148,34 @@ + + + dev + + true + + + dev + + + + prod + + + + + + org.springframework.boot spring-boot-maven-plugin + + + ${spring.profiles.active} + + diff --git a/backend/src/main/java/org/raddatz/familienarchiv/config/DataInitializer.java b/backend/src/main/java/org/raddatz/familienarchiv/config/DataInitializer.java index 8a023693..f4fe4bbb 100644 --- a/backend/src/main/java/org/raddatz/familienarchiv/config/DataInitializer.java +++ b/backend/src/main/java/org/raddatz/familienarchiv/config/DataInitializer.java @@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.CommandLineRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.security.crypto.password.PasswordEncoder; import java.time.LocalDate; @@ -67,6 +68,7 @@ public class DataInitializer { } @Bean + @Profile("dev") public CommandLineRunner initData(PersonRepository personRepo, DocumentRepository docRepo, UserGroupRepository groupRepo) { diff --git a/backend/src/main/resources/application-dev.yaml b/backend/src/main/resources/application-dev.yaml new file mode 100644 index 00000000..45827c3e --- /dev/null +++ b/backend/src/main/resources/application-dev.yaml @@ -0,0 +1,3 @@ +spring: + jpa: + show-sql: true diff --git a/backend/src/main/resources/application.properties b/backend/src/main/resources/application.properties deleted file mode 100644 index 0b132406..00000000 --- a/backend/src/main/resources/application.properties +++ /dev/null @@ -1,28 +0,0 @@ -spring.application.name=Familienarchiv -# --- Datenbank Konfiguration --- -spring.datasource.url=${SPRING_DATASOURCE_URL} -spring.datasource.username=${SPRING_DATASOURCE_USERNAME} -spring.datasource.password=${SPRING_DATASOURCE_PASSWORD} -spring.datasource.driver-class-name=org.postgresql.Driver - -# JPA / Hibernate -spring.jpa.hibernate.ddl-auto=none -spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect -spring.jpa.show-sql=false -# --- MinIO (S3) Konfiguration --- -# Eigene Properties (werden wir in einer Config-Klasse auslesen) -app.s3.endpoint=${S3_ENDPOINT} -app.s3.access-key=${S3_ACCESS_KEY} -app.s3.secret-key=${S3_SECRET_KEY} -app.s3.bucket=${S3_BUCKET_NAME} -app.s3.region=${S3_REGION} - -# Upload Limits erhöhen (für große Scans) -spring.servlet.multipart.max-file-size=50MB -spring.servlet.multipart.max-request-size=50MB -# --- Excel Import Mapping --- -# Spaltenindex (0 = Spalte A, 1 = Spalte B, usw.) -app.import.excel.col.filename=0 -app.import.excel.col.date=1 -app.import.excel.col.location=2 -app.import.excel.col.transcription=3 \ No newline at end of file diff --git a/backend/src/main/resources/application.yaml b/backend/src/main/resources/application.yaml new file mode 100644 index 00000000..a604c24c --- /dev/null +++ b/backend/src/main/resources/application.yaml @@ -0,0 +1,42 @@ +spring: + application: + name: Familienarchiv + + datasource: + url: ${SPRING_DATASOURCE_URL} + username: ${SPRING_DATASOURCE_USERNAME} + password: ${SPRING_DATASOURCE_PASSWORD} + driver-class-name: org.postgresql.Driver + + jpa: + hibernate: + ddl-auto: none + properties: + hibernate: + dialect: org.hibernate.dialect.PostgreSQLDialect + show-sql: false + + servlet: + multipart: + max-file-size: 50MB + max-request-size: 50MB + +app: + s3: + endpoint: ${S3_ENDPOINT} + access-key: ${S3_ACCESS_KEY} + secret-key: ${S3_SECRET_KEY} + bucket: ${S3_BUCKET_NAME} + region: ${S3_REGION} + + admin: + username: ${APP_ADMIN_USERNAME:admin} + password: ${APP_ADMIN_PASSWORD:admin123} + + import: + excel: + col: + filename: 0 + date: 1 + location: 2 + transcription: 3