Ich schreibe eine Grals 3.1.8 Anwendung. Meine Datenquelle wurde in der Datei application.groovy geschrieben.So laden Sie die Datenquellenkonfiguration von externen Dateien in Grails 3.1.8?
Ich möchte Datenquelle Konfiguration wie Benutzername, Passwort, DB aus einer externen Datei laden. Gibt es eine Möglichkeit, es in Grails 3+ Versionen zu tun.
Hier ist meine Datenquelle Konfiguration in application.groovy: -
hibernate {
cache {
queries = false
use_second_level_cache = true
use_query_cache = false
region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory'
}
}
dataSource {
pooled = true
jmxExport = true
dialect = 'org.hibernate.dialect.PostgreSQLDialect'
driverClassName = 'org.postgresql.Driver'
username = 'postgres'
password = 'postgres'
properties = {
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
ignoreExceptionOnPreLoad = true
jdbcInterceptors = "ConnectionState;StatementCache(max=200)"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED // safe default
abandonWhenPercentageFull = 100 // settings are active only when pool is full
removeAbandonedTimeout = 120
removeAbandoned = true
logAbandoned = false // causes stacktrace recording overhead, use only for debugging
}
}
environments {
development {
dataSource {
dbCreate = 'update'
url = "jdbc:postgresql://localhost:5432/testdb"
logSql = true
}
}
test {
dataSource {
dbCreate = 'update'
url = "jdbc:postgresql://localhost:5432/testdb"
logSql = true
}
}
production {
dataSource {
dbCreate = 'update'
url = "jdbc:postgresql://localhost:5432/testdb"
logSql = true
}
}
}
Schöne Antwort. Für mich geht das. – Rassel