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 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-03-15 12:21:16 +01:00
parent 107cec8a2f
commit adee746b23
5 changed files with 70 additions and 28 deletions

View File

@@ -148,11 +148,34 @@
</dependencies>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<spring.profiles.active>dev</spring.profiles.active>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<spring.profiles.active></spring.profiles.active>
</properties>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<profiles>
<profile>${spring.profiles.active}</profile>
</profiles>
</configuration>
</plugin>
</plugins>
</build>

View File

@@ -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) {

View File

@@ -0,0 +1,3 @@
spring:
jpa:
show-sql: true

View File

@@ -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

View File

@@ -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