1

I have a Spring Batch Spring Boot app that needs to be converted to image and later use that in Spring Cloud Data Flow to schedule the job.I have the DEV,UAT,PROD config in

application-properties/dev/application.yml

respectively.We were told to mention the password and username as

password: ${DB_ORCL_PASSWORD}

username: ${DB_ORCL_USER}

I am not sure how the credentials get substituted based on the environment. Is it something i should provide while building the docker image?

2

2 Answers 2

0

Its spring frameworks feature for externalised configuration.

The values in application.properties and application.yml are filtered through the existing Environment when they are used, so you can refer back to previously defined values (for example, from System properties). The standard ${property-value} property-placeholder syntax can be used anywhere within a value.

Note : You need to set environment variables with same property key name in all your environments. Rendering the property values with the values given in environment variables are done by spring. You don't have to worry about that.

Property Placeholders

Sign up to request clarification or add additional context in comments.

Comments

0

Create different profiles based on the environment where you specify the different username and password: application-dev.yml, application-uat.yml and application-prod.yml. Each profile can be run by java -jar --spring.profiles.active=<profile>. For more details: https://www.baeldung.com/spring-profiles.

For the image, you can specify the entrypoint using the java command with the profile. See this question: How can I start spring boot application in docker with profile?.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.