From c15c7e31d018a9b0e379f970c813f519ed8131d9 Mon Sep 17 00:00:00 2001 From: nhkhai Date: Thu, 2 May 2024 14:19:12 +0800 Subject: [PATCH] Added additional Spring profiles. --- .../application-development.properties | 74 +++++++++++++++++++ .../application-production.properties | 74 +++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 src/main/resources/application-development.properties create mode 100644 src/main/resources/application-production.properties diff --git a/src/main/resources/application-development.properties b/src/main/resources/application-development.properties new file mode 100644 index 0000000..c84cfd6 --- /dev/null +++ b/src/main/resources/application-development.properties @@ -0,0 +1,74 @@ +spring.application.name=smart-inventory + +# Server Port Configuration. +# The default server port is 8080. +server.port=${PORT:9090} + +# Database Configuration. +# PostgreSQL. +spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/the_review_room} +# For WSL, use postgres. +# For Mac, use your Mac username. +spring.datasource.username=${SPRING_DATASOURCE_USERNAME:postgres} +# Password can be blank if we set it to trust in pg_hba.conf. +spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:} + +# Database platform to use. +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect + +# Hibernate Database Initialization Method. +# This will drop and create tables again. +spring.jpa.hibernate.ddl-auto=create +# This can be used to update tables. +# spring.jpa.hibernate.ddl-auto=update + +# Logging configuration. +# Application logging configuration. +# logging.level.root=INFO +# logging.file.name=logs/application.log + +# Database logging configuration. +# The Spring/Hibernate classes, which generate SQL statements and set the parameters, already contain the code for logging them. +# However, the level of those log statements is set to DEBUG and TRACE respectively, which is lower than the default level in Spring Boot — INFO. +# By adding these properties, we are just setting those loggers to the required level. +# For logging statements. +# logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG + +# For logging parameters of prepared statements. +# logging.level.org.springframework.jdbc.core.StatementCreatorUtils=TRACE + +# Set up a profile-specific configuration for tests. For example a profile. +# logging.config=classpath:logback-testloglevel.xml + +# SpringDoc Configuration. +# The OpenAPI descriptions are at /v3/api-docs, which is the default path: http://localhost:8080/v3/api-docs. +# For a custom path of the OpenAPI documentation in Json format, +# add the custom springdoc property /api-docs endpoint custom path to get the path: http://localhost:8080/api-docs. +springdoc.api-docs.path=/api-docs + +# The OpenAPI definitions are in JSON format by default. For yaml format, we can obtain the definitions at: http://localhost:8080/api-docs.yaml. +# To disable api-docs springdoc-openapi endpoints. +# springdoc.api-docs.enabled=false + +# The springdoc-openapi dependency already includes Swagger UI, to integrate springdoc-openapi with Swagger UI to interact with our API specification and exercise the endpoints.# We can access the API documentation at: http://localhost:8080/swagger-ui/index.html. +# Using swagger-ui properties, to customize the path of the swagger-ui API documentation swagger-ui-custom.html to get the path: http://localhost:8080/swagger-ui-custom.html. +# springdoc.swagger-ui.path=/swagger-ui-custom.html +springdoc.swagger-ui.path=/swagger-ui.html + +# To sort the API paths according to their HTTP methods with the springdoc.swagger-ui.operationsSorter property. +# springdoc.swagger-ui.operationsSorter=method + +# Jwt details. +# https://medium.com/code-with-farhan/spring-security-jwt-authentication-authorization-a2c6860be3cf +# jwt.session.period=60000 + +# Profile management. +# Spring Boot will always read the application.properties file. +# Other's profile files, such as application-development.properties only will complement and replace the properties defined before. +# The application.properties, and just this file, must have this line. +# spring.profiles.active=@spring.profiles.active@ +# Set the default active profile. +# Use the command to activate: mvn spring-boot:run -Dspring.profiles.active=development. +spring.profiles.active=${SPRING_PROFILES_ACTIVE:development} +# Set the default default profile. This is the profile that is used on any bean if you don't specify the @Profile annotation to be a certain profile. +# spring.profiles.default=development diff --git a/src/main/resources/application-production.properties b/src/main/resources/application-production.properties new file mode 100644 index 0000000..c84cfd6 --- /dev/null +++ b/src/main/resources/application-production.properties @@ -0,0 +1,74 @@ +spring.application.name=smart-inventory + +# Server Port Configuration. +# The default server port is 8080. +server.port=${PORT:9090} + +# Database Configuration. +# PostgreSQL. +spring.datasource.url=${SPRING_DATASOURCE_URL:jdbc:postgresql://localhost:5432/the_review_room} +# For WSL, use postgres. +# For Mac, use your Mac username. +spring.datasource.username=${SPRING_DATASOURCE_USERNAME:postgres} +# Password can be blank if we set it to trust in pg_hba.conf. +spring.datasource.password=${SPRING_DATASOURCE_PASSWORD:} + +# Database platform to use. +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect + +# Hibernate Database Initialization Method. +# This will drop and create tables again. +spring.jpa.hibernate.ddl-auto=create +# This can be used to update tables. +# spring.jpa.hibernate.ddl-auto=update + +# Logging configuration. +# Application logging configuration. +# logging.level.root=INFO +# logging.file.name=logs/application.log + +# Database logging configuration. +# The Spring/Hibernate classes, which generate SQL statements and set the parameters, already contain the code for logging them. +# However, the level of those log statements is set to DEBUG and TRACE respectively, which is lower than the default level in Spring Boot — INFO. +# By adding these properties, we are just setting those loggers to the required level. +# For logging statements. +# logging.level.org.springframework.jdbc.core.JdbcTemplate=DEBUG + +# For logging parameters of prepared statements. +# logging.level.org.springframework.jdbc.core.StatementCreatorUtils=TRACE + +# Set up a profile-specific configuration for tests. For example a profile. +# logging.config=classpath:logback-testloglevel.xml + +# SpringDoc Configuration. +# The OpenAPI descriptions are at /v3/api-docs, which is the default path: http://localhost:8080/v3/api-docs. +# For a custom path of the OpenAPI documentation in Json format, +# add the custom springdoc property /api-docs endpoint custom path to get the path: http://localhost:8080/api-docs. +springdoc.api-docs.path=/api-docs + +# The OpenAPI definitions are in JSON format by default. For yaml format, we can obtain the definitions at: http://localhost:8080/api-docs.yaml. +# To disable api-docs springdoc-openapi endpoints. +# springdoc.api-docs.enabled=false + +# The springdoc-openapi dependency already includes Swagger UI, to integrate springdoc-openapi with Swagger UI to interact with our API specification and exercise the endpoints.# We can access the API documentation at: http://localhost:8080/swagger-ui/index.html. +# Using swagger-ui properties, to customize the path of the swagger-ui API documentation swagger-ui-custom.html to get the path: http://localhost:8080/swagger-ui-custom.html. +# springdoc.swagger-ui.path=/swagger-ui-custom.html +springdoc.swagger-ui.path=/swagger-ui.html + +# To sort the API paths according to their HTTP methods with the springdoc.swagger-ui.operationsSorter property. +# springdoc.swagger-ui.operationsSorter=method + +# Jwt details. +# https://medium.com/code-with-farhan/spring-security-jwt-authentication-authorization-a2c6860be3cf +# jwt.session.period=60000 + +# Profile management. +# Spring Boot will always read the application.properties file. +# Other's profile files, such as application-development.properties only will complement and replace the properties defined before. +# The application.properties, and just this file, must have this line. +# spring.profiles.active=@spring.profiles.active@ +# Set the default active profile. +# Use the command to activate: mvn spring-boot:run -Dspring.profiles.active=development. +spring.profiles.active=${SPRING_PROFILES_ACTIVE:development} +# Set the default default profile. This is the profile that is used on any bean if you don't specify the @Profile annotation to be a certain profile. +# spring.profiles.default=development