Created
October 27, 2015 16:47
-
-
Save jkschneider/41f94d7fbc6056581f25 to your computer and use it in GitHub Desktop.
Differentiating between local and cloud deployments (Spring Boot)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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