feat: added spring profile setup for env variables

This commit is contained in:
filippo-ferrari 2024-09-07 16:06:53 +02:00
parent c4b9c14706
commit 91d4f4245f
4 changed files with 10 additions and 2 deletions

3
.gitignore vendored
View file

@ -6,6 +6,9 @@
.classpath .classpath
.env .env
# Ignore profile-specific properties files
application-*.properties
*.iml *.iml
.DS_Store .DS_Store

View file

@ -7,7 +7,7 @@ services:
ports: ports:
- "8080:8080" - "8080:8080"
environment: environment:
SPRING_DATASOURCE_URL: ${DB_ADDRESS} SPRING_DATASOURCE_URL: ${DB_ADDRESS}/${DB_NAME}
SPRING_DATASOURCE_USERNAME: ${DB_USER} SPRING_DATASOURCE_USERNAME: ${DB_USER}
SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD} SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD}
depends_on: depends_on:

View file

@ -3,13 +3,14 @@ package com.application.munera;
import com.application.munera.repositories.ExpenseRepository; import com.application.munera.repositories.ExpenseRepository;
import com.vaadin.flow.component.page.AppShellConfigurator; import com.vaadin.flow.component.page.AppShellConfigurator;
import com.vaadin.flow.theme.Theme; import com.vaadin.flow.theme.Theme;
import javax.sql.DataSource;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.sql.init.SqlDataSourceScriptDatabaseInitializer; import org.springframework.boot.autoconfigure.sql.init.SqlDataSourceScriptDatabaseInitializer;
import org.springframework.boot.autoconfigure.sql.init.SqlInitializationProperties; import org.springframework.boot.autoconfigure.sql.init.SqlInitializationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import javax.sql.DataSource;
/** /**
* The entry point of the Spring Boot application. * The entry point of the Spring Boot application.
* *

View file

@ -2,12 +2,16 @@ server.port=${PORT:8080}
logging.level.org.atmosphere = warn logging.level.org.atmosphere = warn
spring.mustache.check-template-location = false 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 # Launch the default browser when starting the application in development mode
#vaadin.launch-browser=true #vaadin.launch-browser=true
# PostgreSQL configuration. # PostgreSQL configuration.
spring.datasource.url = ${DB_ADDRESS}/${DB_NAME} spring.datasource.url = ${DB_ADDRESS}/${DB_NAME}
spring.datasource.username = ${DB_USER} spring.datasource.username = ${DB_USER}
spring.datasource.password = ${DB_PASSWORD} spring.datasource.password = ${DB_PASSWORD}
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto = update spring.jpa.hibernate.ddl-auto = update
# To improve the performance during development. # To improve the performance during development.
# For more information https://vaadin.com/docs/latest/integrations/spring/configuration#special-configuration-parameters # For more information https://vaadin.com/docs/latest/integrations/spring/configuration#special-configuration-parameters