https://github.com/lightbend/config
In version 0.0.9 added support for generating yaml files. Also retained support for the old format |
cmd/app generate cfg |
All comands related to generation you can find in this file cmd/app |
postgres: enabled: false name: "POSTGRES" driverClassName: "org.postgresql.Driver" jdbcUrl: "jdbc:postgresql://localhost:5432/playground_db" locationMigration: "classpath:db/migration/postgres" propertyPath: "postgres.jdbcUrl" users: runtime: "playground" flyway: "playground" passwords: runtime: "playground" flyway: "playground" hikari: connectionTimeout: 45000 idleTimeout: 60000 maxLifetime: 180000 maximumPoolSize: 50 minimumIdle: 5 connectionInitSql: "SELECT 1" connectionTestQuery: "SELECT 1" poolName: "core-postgres-db-pool" autoCommit: true |
GlobalConfiguration.Postgres postgres = globalConfiguration.postgres(); FluentConfiguration fluentConfiguration = Flyway.configure() .dataSource(postgres.jdbcUrl(), postgres.users().flyway(), postgres.passwords().flyway()) .sqlMigrationPrefix("") .locations(postgres.locationMigration()) .baselineOnMigrate(true); Flyway flyway = fluentConfiguration.load(); flyway.migrate(); |
Where we connect GlobalConfiguration as a bean and get a subclass postgres() with all the setting for the database |