Skip to content

Instantly share code, notes, and snippets.

@jkschneider
Created October 27, 2015 16:47
Show Gist options
  • Save jkschneider/41f94d7fbc6056581f25 to your computer and use it in GitHub Desktop.
Save jkschneider/41f94d7fbc6056581f25 to your computer and use it in GitHub Desktop.
Differentiating between local and cloud deployments (Spring Boot)
@SpringBootApplication
open class MyService: SpringBootServletInitializer() {
companion object {
// used for local development only
@JvmStatic fun main(args: Array<String>) {
SpringApplicationBuilder(MyService::class.java).profiles("local").run(*args)
}
}
// only executes when running inside of Tomcat standalone -- which only occurs in the
// deployed environment
override fun run(application: SpringApplication): WebApplicationContext {
application.setAdditionalProfiles("cloud")
return super.run(application)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment