From 91d4f4245f8241a2a243ac2e7c7316d7686a4300 Mon Sep 17 00:00:00 2001 From: filippo-ferrari Date: Sat, 7 Sep 2024 16:06:53 +0200 Subject: [PATCH] feat: added spring profile setup for env variables --- .gitignore | 3 +++ docker-compose.yml | 2 +- src/main/java/com/application/munera/Application.java | 3 ++- src/main/resources/application.properties | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 739b6cf..f980e8d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ .classpath .env +# Ignore profile-specific properties files +application-*.properties + *.iml .DS_Store diff --git a/docker-compose.yml b/docker-compose.yml index ab65e4b..dc1f0b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,7 +7,7 @@ services: ports: - "8080:8080" environment: - SPRING_DATASOURCE_URL: ${DB_ADDRESS} + SPRING_DATASOURCE_URL: ${DB_ADDRESS}/${DB_NAME} SPRING_DATASOURCE_USERNAME: ${DB_USER} SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD} depends_on: diff --git a/src/main/java/com/application/munera/Application.java b/src/main/java/com/application/munera/Application.java index ea681e3..0082f34 100644 --- a/src/main/java/com/application/munera/Application.java +++ b/src/main/java/com/application/munera/Application.java @@ -3,13 +3,14 @@ package com.application.munera; import com.application.munera.repositories.ExpenseRepository; import com.vaadin.flow.component.page.AppShellConfigurator; import com.vaadin.flow.theme.Theme; -import javax.sql.DataSource; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.sql.init.SqlDataSourceScriptDatabaseInitializer; import org.springframework.boot.autoconfigure.sql.init.SqlInitializationProperties; import org.springframework.context.annotation.Bean; +import javax.sql.DataSource; + /** * The entry point of the Spring Boot application. * diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fd13d90..d3d3cc6 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,12 +2,16 @@ server.port=${PORT:8080} logging.level.org.atmosphere = warn spring.mustache.check-template-location = false +# Activate the default profile +spring.profiles.active=dev + # Launch the default browser when starting the application in development mode #vaadin.launch-browser=true # PostgreSQL configuration. spring.datasource.url = ${DB_ADDRESS}/${DB_NAME} spring.datasource.username = ${DB_USER} spring.datasource.password = ${DB_PASSWORD} +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect spring.jpa.hibernate.ddl-auto = update # To improve the performance during development. # For more information https://vaadin.com/docs/latest/integrations/spring/configuration#special-configuration-parameters