<p>we have three environment as (dev, test and prod) and we have database configuration as below</p>

<pre><code>spring:
  jpa:
    hibernate:
      ddl-auto: update
  datasource:
    url: ${URL}
    username: ${USERNAME}
    password: ${PASSWORD}
</code></pre>

<p>What i am trying is that i create the jar and then build the image and when deploying in to the kubernetes , i will be using the dev , test and prod respective deployment.yaml in which i will be loading the url,username and password to env so the application will read it during prod start up</p>

<p>So when i am trying to build jar application try to connect to the database and it failed to create the jar.</p>

<p>Please let me know my understanding is wrong or right if wrong then how to correct it and just one thing is that i can't change the process i.e jar+ image + kubernetes</p>

<p>In Kubernetes you can put your configuration in Configmap or Secret. You can package the spring boot application and provide the Configmap entry as env variable of your container as exposed <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-container-environment-variables-using-configmap-data" rel="nofollow noreferrer">here</a></p>

<p>Using Spring Cloud Kubernetes you can also read these properties without any configuration on the container as explained in this <a href="https://link.medium.com/26PPT5XZYZ" rel="nofollow noreferrer">article</a></p>
