Spring Boot + Gradle - where to put environment configuration?

Viewed 8565

I was working on a simple application in Spring Boot. It was developed locally (and it works) with:

  • Gradle,
  • H2 database with connection properties set in application.properties placed on project's root
  • Maven folders structure (src/main/groovy, src/main/resources, etc.)

Now it's the time when I'd like to deploy it to the Openshift, so I need to create an additional, production configuration with a MySQL settings, but I don't know where to put it and how to use it.

So my questions are:

  1. What should I do to have two different configurations (development and production)?
  2. Where to put the configuration files?
  3. Do I have to change something in the build.gradle?
  4. How to build the app with a development or production config?
  5. How to run the app with a development or production config?
  6. What are the best practices for creating multiple environment configurations?

I'm rather a frontend dev and all these backend stuff are not obvious for me, so please consider it in your answers.

This is the content of my current build.gradle

plugins {
    id 'org.springframework.boot' version '1.5.3.RELEASE'
    id 'java'
    id 'groovy'
}

jar {
    baseName = 'myproject'
    version =  '0.0.1-SNAPSHOT'
}

repositories {
    jcenter()
}

dependencies {
    compile("org.springframework.boot:spring-boot-starter-web")
    testCompile("org.springframework.boot:spring-boot-starter-test")
    compile("org.springframework.boot:spring-boot-starter-data-jpa")
    compile 'mysql:mysql-connector-java'
    compile("com.h2database:h2")
    compile("org.springframework.boot:spring-boot-starter-security")
    compile('io.jsonwebtoken:jjwt:0.7.0')
    compile localGroovy()
}
2 Answers
Related