I have a spring boot app that I d like to deploy on Google app engine using the app engine maven plugin.
Everything works fine except I cannot find a way that Google app engine loads the correct application.properties file for the spring boot app.
I have application-prod.properties, application-default.properties and application-test.properties. Locally I can easily choose which environment/profile to start using for example
mvn appengine:run -Dspring.profiles.active=prod
But when I try to do the same for the deploy job, like
mvn appengine:deploy -Dspring.profiles.active=prod
That does not work. It does not load application-prod.properties but falls back to application-default.properties.
Do I missunderstand something or should that work? If that won't work since Google app engine just starts the war without passing in any param, is there a way to define environment variables for the app/service on Google where I can store stuff like database url and credentials that are environment specific?
Thanks for your help guys.
Configure Google Cloud Platform Console and SDK. Use Cloud SQL to create a MySQL instance. Configure the application for Spring Cloud GCP. Deploy the application to App Engine and test it.
If using App Engine flexible environment, in your app.yaml
add the following
env_variables:
JAVA_USER_OPTS: '-Dspring.profiles.active=prod'
This will be added to the JVM start command by the runtime. See documentation for the openjdk-runtime. By default, your app is using the jetty-runtime, which inherits the options from the openjdk-runtime.
If using App Engine standard environment, in your appengine-web.xml
add the following:
<system-properties>
<property name="spring.profiles.active" value="prod" />
</system-properties>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With