Browse Source

Add explicit database connection properties for dev & prod profiles

Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.4-alpha
Pekka Helenius 4 years ago
parent
commit
e5e72eb41d
5 changed files with 64 additions and 66 deletions
  1. +2
    -12
      bookstore/src/main/resources/application-dev.properties
  2. +2
    -53
      bookstore/src/main/resources/application-prod.properties
  3. +1
    -1
      bookstore/src/main/resources/application.properties
  4. +8
    -0
      bookstore/src/main/resources/database-dev.properties
  5. +51
    -0
      bookstore/src/main/resources/database-prod.default.properties

+ 2
- 12
bookstore/src/main/resources/application-dev.properties View File

@ -1,19 +1,9 @@
# Pekka Helenius <fincer89@hotmail.com>, Fjordtek 2020
# Development configuration
# Temporary, volatile database
spring.h2.console.enabled = true
spring.h2.console.path = /h2-console
# Ref: http://h2database.com/html/features.html
#
spring.datasource.url = jdbc:h2:mem:testdb;MODE=MySQL
spring.jpa.show-sql = true
# NOTE: Database configuration should be provided in additional
# database-dev.properties file.
management.endpoints.enabled-by-default = true
management.endpoints.web.exposure.include = *

+ 2
- 53
bookstore/src/main/resources/application-prod.properties View File

@ -1,57 +1,6 @@
# Pekka Helenius <fincer89@hotmail.com>, Fjordtek 2020
# Production configuration
# Persistent database
spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/<DATABASE_NAME>?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username = <DATABASE_USERNAME>
spring.datasource.password = <DATABASE_PASSWORD>
spring.datasource.initialization-mode = always
spring.h2.console.enabled = false
spring.jpa.show-sql = false
# Disable auto-IDs, let SQL server handle them
spring.jpa.hibernate.use-new-id-generator-mappings = false
# Hibernate (& SQL server) table naming strategy
# NOTE: SQL server // Unix environments
#
# Table names are case sensitive.
# For more information, see
# https://dev.mysql.com/doc/refman/8.0/en/identifier-case-sensitivity.html
#
# Most notable the following part:
#
# "...such (table) names are not case-sensitive in Windows, but are case-sensitive in
# most varieties of Unix. One notable exception is macOS, which is Unix-based
# but uses a default file system type (HFS+) that is not case-sensitive."
#
# If required, configure [mysqld] section in
# SQL server configuration file (Unix: usually /etc/mysql/my.cnf OR /etc/my.cnf),
# especially configuration entry 'lower_case_table_names'
#
# Please remember, when creating table schema (resources/schema.sql),
# and configuring @Table annotation naming scheme for tables,
# consider the following factors:
#
# 1) Target SQL server environment*
# - SQL server naming policy configuration
# - SQL server operating system environment (see reference link & quote above)
#
# 2) Defined letter case used in @Table annotation name parameters in this
# application context. Practically meaning any classes defined as Jakarta
# Persistence entities (classes with @Entity annotations).
#
# *If unsure, contact your SQL server administrator to get required assistance
# for your application configuration.
#
spring.jpa.hibernate.naming.physical-strategy = org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
#spring.jpa.hibernate.ddl-auto = validate
# NOTE: Database configuration should be provided in additional
# database-prod.properties file.

+ 1
- 1
bookstore/src/main/resources/application.properties View File

@ -7,7 +7,7 @@
# dev :: for development
# prod :: for production
#
spring.profiles.active = dev
spring.profiles.active = prod
# Default HTTP TCP port number for this server application
# Do not set this value below 1024 as these TCP/UDP ports are privileged, requiring root permissions


+ 8
- 0
bookstore/src/main/resources/database-dev.properties View File

@ -0,0 +1,8 @@
# Temporary, volatile database
spring.h2.console.enabled = true
spring.h2.console.path = /h2-console
# Ref: http://h2database.com/html/features.html
#
spring.datasource.url = jdbc:h2:mem:testdb;MODE=MySQL
spring.jpa.show-sql = true

+ 51
- 0
bookstore/src/main/resources/database-prod.default.properties View File

@ -0,0 +1,51 @@
# Persistent database
spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/<DB_DATABASE_NAME>?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username = <DB_USERNAME>
spring.datasource.password = <DB_PASSWORD>
spring.datasource.initialization-mode = always
spring.h2.console.enabled = false
spring.jpa.show-sql = false
# Disable auto-IDs, let SQL server handle them
spring.jpa.hibernate.use-new-id-generator-mappings = false
# Hibernate (& SQL server) table naming strategy
# NOTE: SQL server // Unix environments
#
# Table names are case sensitive.
# For more information, see
# https://dev.mysql.com/doc/refman/8.0/en/identifier-case-sensitivity.html
#
# Most notable the following part:
#
# "...such (table) names are not case-sensitive in Windows, but are case-sensitive in
# most varieties of Unix. One notable exception is macOS, which is Unix-based
# but uses a default file system type (HFS+) that is not case-sensitive."
#
# If required, configure [mysqld] section in
# SQL server configuration file (Unix: usually /etc/mysql/my.cnf OR /etc/my.cnf),
# especially configuration entry 'lower_case_table_names'
#
# Please remember, when creating table schema (resources/schema.sql),
# and configuring @Table annotation naming scheme for tables,
# consider the following factors:
#
# 1) Target SQL server environment*
# - SQL server naming policy configuration
# - SQL server operating system environment (see reference link & quote above)
#
# 2) Defined letter case used in @Table annotation name parameters in this
# application context. Practically meaning any classes defined as Jakarta
# Persistence entities (classes with @Entity annotations).
#
# *If unsure, contact your SQL server administrator to get required assistance
# for your application configuration.
#
spring.jpa.hibernate.naming.physical-strategy = org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
#spring.jpa.hibernate.ddl-auto = validate

Loading…
Cancel
Save