So in general,if you some application properties which vary per environment,you can handle that with the help of Spring Profiles.Ģ.1 Follow my post How to Create a Spring Boot Project with Spring Initializer and create a Spring Boot project with name “Springbootprofiles” .Add only web dependency,as that will be sufficient for our testing.Ģ.2 In the application. Spring Boot Profiles allow you to configure multiple application.properties file, per environment,so that when you are on local ,it will use local properties file,when you are on DEV it will use DEV properties file and so on ,without you as a programmer need to make any explicit changes in the code. Spring Boot lets you externalize your application configuration so that you can work with same application code in different environments without you need to make changes. Now Imagine you have more environments like ST,ET(QA),PROD and you have to make changes manually all the times.It will be real nightmare. So again to make it work on your local,you will have to make changes in the application.properties which are required for local and execute the application.Īs you can see,there is lot of hustle involved here in shuffling between local and DEV. So what you can do is,you can change application.properties file with the details which are required to connect to the DEV database,commit the code and deploy it on DEV,but the problem now is this code will connect fine with DEV database but when you will try to execute this code from local,it would not work,because you have changed database details to DEV database. Now while testing the application locally,in your application.properties file,you would have put details like database url,username,password which is for the local database which is installed on your machine,but once you move to DEV environment,you would like your application to talk to DEV database rather than local database. Suppose,you are working on a Spring Boot Application.You have tested application locally on your machine by connecting to local database which is installed on your machine.Now you want to deploy this application on DEV environment and you have DEV database server as well where you have your database. How to do Profiling in Spring Boot with Example What is Spring Boot Profile and Why we need ProfilingĢ. We will discuss following points in this tutorial :ġ.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |