I personally like your tutorials. Could you also start a tutorial of any cloud (Aws/Azure/GCP) after micro service. It would be really helpful if you could do so.
I am an IT professional but your videos makes me travel back to my college days where I was blessed with some excellent professors. Thanks to you , the way you explain gives me opportunity to feel like I am in the same classroom and you are one of those excellent professors. I personally like your explanation because answer all WHY questions. We know WHAT to use where but you emphasise more on WHY should we use that.
this is why I'm, again and again, fall in love with java brains, Thank you java brains for enhancing my skills of 'spring profiles'. this is very helpful for me in development. I'm waiting for the actual microservice series.
Note - This method will work till spring boot 2.3. Starting from 2.4 there can be one single application.properties file separated by #--- for env specific values using spring.config.activate.on-profile= at the start followed by the env specific values
Thank you. Your tutorials are just too good. In this particular context of spring profiles, I would like to add I needed to start my application with TWO profiles active... My React front end was facing CORS issue when accessing my spring boot backend - so had a special bean with a @Profile("corsSecurity") and to have TWO profiles (dev and prod) had this in my default application.properties spring.profiles.group.dev=dev,corsSecurity spring.profiles.group.prod=prod,corsSecurity and started my application with either java -jar --spring.profiles.active=dev or --spring.profiles.active=prod
Hey man, this was amazing. Before this video I was wondering how I was gonna set up profiles in maven! It's such a relief that this could be done via jar. Thank you very much!
thumbs up for him to sell some merch. I've watch enough of your vids to justify buying some. Think of a nice pc sticker, or cooler sticker. JB-Vids!?!?
V Good explanation. One question , if everything remains in jar , and we have to say change some config value for prod , do we need to change the jar to include that new config value? As the production config sits in jar. We will have to build the code again to generate new build version. Isn't? M I missing something?
Hi @JavaBrains , if we define @Profile("dev") on class say ABC then only ABC class bean will be instantiated in whole application when ran in dev environment, is my understanding correct ? can you share your thoughts over this ?
at 9:10 you said it overrides but i faced this issue, I did exactly what you did with previous project rather then creating new project with just web dependency, i was able to have two properties but new properties file was not overriding values written in default properties file, but moment i switched to yaml files overriding worked. can someone tell me why?
Hi Kaushik, thanks for the awesome tutorial, my question , is it possible to define profiles for external Property Files and configuration (properties) without using for example application.prop or Is it also possible to have profiles for external Property Files and configurations.
As always thank you for the great video. On a completely different topic, I am curious to know why you are using package view as opposed to the project files in IntelliJ project explorer. In my optional project view is more intuitive and exactly represents the actual folder structure. That's one of the reasons I switched to intelliJ.
12 step process architecture doesn't like it but selecting beans based upon external input, ie. config file, brings Spring back to inversion of control and code-reuse, which it seems to lose with annotations.
at 9:10 you said two properties files can be there in our project but when they are present at same location (src/main/resources) overriding is not working , different profile gets selected but values are not overridden, but two yaml files work how you told even in same location.
what about unit tests? what profile will they use? how to control it? is it possible to have test profile that will not make it's way to the artifact and will be used only in the tests scope?
I'm enjoying these videos, I really like how they are structured around the desirable properties a configuration system should have. I have a question about the "default profile", though. Is it really correct to say that it's "always active"? My understanding is that, as soon as a different profile is explicitly set with "spring.profiles.active", beans in the default profile won't get loaded into the context. Even beans that are not "overridden" by the explicit profile. Also, is it correct to say (around 15:00) that setting @Profile("default") and not including any @Profile annotation in a bean are equivalent? I believe that no @Profile = "always present", while @Profile("default") = "present only when no explicit profile is given".
Question: Lets say you have a bean called Repository( in source code with active profile "production") in source code , in test (folder, for functional tests) having another Bean called Repository( to connect embedded H2 instead of actual DB) with active profile as "test" , when we run application will test bean will be injected to container? (It does not worked for me)
@@ayushgupta8239 - we are running test base class with with @activeprofile as test, qq: will spring context will consider Repository bean which is in src/test/jav?
I needed a bean for an integration test. I didn't use a profile annotation so it was instantiated via the default profile. I could see that in the log. However, I got no bean found when autowiring it into my integration test. How can that be when I could see that the bean had been created?
is it ok to have no default profile in the aplication and provide it manually for each environment with only the profile name in it? this could protect from running application with a wrong profile
You can, but remember that there’s always a default profile active. So, even if you have one configuration value in your app that’s common across all profiles, it would be silly to duplicate it across all your profiles. Hope that clarifies
i added this property on application-test.yml file spring.profiles.active: test Still it load the default profile. i am using the spring boot v2.2.4.RELEASE. is there any more change to do ?
@@bikramnarayankundu2924 Suppose i have three version of the profile. 1. Dev 2. QA 3. PROD i need to keep three separate files for the three env, correct me if i am wrong. so in that case, based on the requirement, we will add the "spring.profiles.active: test" i the file name application-test.yml as per the naming convention.. application-.yml eg:: application-test.yml, applciation-dev.yml, application-prod.yml
@@bishwajitvikram3794 I guess this is wrong... 1. Have all the files 2. Just change the application.yml file with the property spring.profiles.active: Dev Or spring.profiles.active: QA Or spring.profiles.active: PROD
Awesome tutorial! Thanks for putting this up! One confusion I still have is, you mention about having multiple configurations (as a result of multiple profiles) in one jar file at ua-cam.com/video/P91tqdWUHE4/v-deo.html. But wouldn't it be ideal to separate out config from the jar files similar to ua-cam.com/video/P91tqdWUHE4/v-deo.html because configs have a different lifecycle than the application itself. For instance, I do not need to release a new version of a jar for a config change.
I personally like your tutorials. Could you also start a tutorial of any cloud (Aws/Azure/GCP) after micro service. It would be really helpful if you could do so.
I am an IT professional but your videos makes me travel back to my college days where I was blessed with some excellent professors. Thanks to you , the way you explain gives me opportunity to feel like I am in the same classroom and you are one of those excellent professors. I personally like your explanation because answer all WHY questions. We know WHAT to use where but you emphasise more on WHY should we use that.
this is why I'm, again and again, fall in love with java brains, Thank you java brains for enhancing my skills of 'spring profiles'. this is very helpful for me in development. I'm waiting for the actual microservice series.
I searched half the web how it works..(and naming convention in profile!) Java Brains explains and I get it at once!
I watched this course in most rated paid online learning platform. That is no where near to your explnation. Koushik Your are The Man.
If this video is spring bean, it goes to @Profile("Awesome Explanation") ❤
Lol
I never want disappointed by the Explanation of Sir.
Thanks for your videos !!!
You are always the Best.
Note - This method will work till spring boot 2.3. Starting from 2.4 there can be one single application.properties file separated by #--- for env specific values using spring.config.activate.on-profile= at the start followed by the env specific values
This is a very good explanation of what @Profile is. Thanks!
Thank you. Your tutorials are just too good.
In this particular context of spring profiles, I would like to add
I needed to start my application with TWO profiles active...
My React front end was facing CORS issue when accessing my spring boot backend
- so had a special bean with a @Profile("corsSecurity")
and to have TWO profiles (dev and prod) had this in my default application.properties
spring.profiles.group.dev=dev,corsSecurity
spring.profiles.group.prod=prod,corsSecurity
and started my application with either
java -jar --spring.profiles.active=dev or --spring.profiles.active=prod
Very helpful tutorial for learning profile in spring boot , I like the way that sir explain with real time examples in coding.
Really liked your tutorials. I was confused that how exactly the profiles are being choosed. You explain it quite nice👌
Trust me this guy is a genius
Nice explanation as always! Please start another series for deploying micro services
Amazing. Perfect mix between theory and practice. Thanks!
You are doing a fantastic job Sir
Hey man, this was amazing. Before this video I was wondering how I was gonna set up profiles in maven! It's such a relief that this could be done via jar.
Thank you very much!
Thankyou. Clear, informative and to the point. Spring profiles...done
In this era of netflix and stuff, I am glad to binge watch these 😎
Happy Republic Day Koushik.!
Yours videos are so helpful! Thank you!
Nice tutorial... pls see if you can put something on exception in spring boot
Very useful I like the way you explain...Thanks
thumbs up for him to sell some merch. I've watch enough of your vids to justify buying some. Think of a nice pc sticker, or cooler sticker. JB-Vids!?!?
Great tutorial so far! Can you please have a tutorial for JWT
Lovely...very crisp and clear 👌👌
Great tutorial!! This is what i was looking for implement in my project.
Great Thank you for the video series
Thank you for such great explanation
great sir god bless you thanks for helping
Awesome Koushik..
Nice Tutorial !! One question Can we set XSD of mainframe environment with specific properties with Spring Profiles?
Amazing explanation!
Please start series for AWS core services
Огромное, СПАСИБО! Ты просто молодец! :)
@Java Brains - Is there a way I can get in contact with you? I would very much appreciate that. Thank you.
Also, we can have multiple profiles configured under one config file. Can u explain a bit about it how to set it
Can you please publish Microservice Saga or event sourcing example. Thanks
Very good sir.
V Good explanation.
One question , if everything remains in jar , and we have to say change some config value for prod , do we need to change the jar to include that new config value? As the production config sits in jar. We will have to build the code again to generate new build version. Isn't? M I missing something?
Thanks Kaushik. Is there any chance you will share the GIT link of all the programs you explain the concepts on?
very cool lesson 👍
Hi @JavaBrains , if we define @Profile("dev") on class say ABC then only ABC class bean will be instantiated in whole application when ran in dev environment, is my understanding correct ?
can you share your thoughts over this ?
Nice explanation
Have one doubt how can I change the profile in pcf using command line
I think in manifest-env.yml we need to write active profile name
Brilliant tutorial! Thank you so much!
at 9:10 you said it overrides but i faced this issue,
I did exactly what you did with previous project rather then creating new project with just web dependency, i was able to have two properties but new properties file was not overriding values written in default properties file, but moment i switched to yaml files overriding worked.
can someone tell me why?
Hi Kaushik, thanks for the awesome tutorial, my question , is it possible to define profiles for external Property Files and configuration (properties) without using for example application.prop or Is it also possible to have profiles for external Property Files and configurations.
As always thank you for the great video. On a completely different topic, I am curious to know why you are using package view as opposed to the project files in IntelliJ project explorer. In my optional project view is more intuitive and exactly represents the actual folder structure. That's one of the reasons I switched to intelliJ.
12 step process architecture doesn't like it but selecting beans based upon external input, ie. config file, brings Spring back to inversion of control and code-reuse, which it seems to lose with annotations.
can we have beans configured for a specific profile but without corresponding specific property file?
at 9:10 you said two properties files can be there in our project but when they are present at same location (src/main/resources) overriding is not working , different profile gets selected but values are not overridden, but two yaml files work how you told even in same location.
what about unit tests? what profile will they use? how to control it? is it possible to have test profile that will not make it's way to the artifact and will be used only in the tests scope?
I'm enjoying these videos, I really like how they are structured around the desirable properties a configuration system should have.
I have a question about the "default profile", though. Is it really correct to say that it's "always active"? My understanding is that, as soon as a different profile is explicitly set with "spring.profiles.active", beans in the default profile won't get loaded into the context. Even beans that are not "overridden" by the explicit profile.
Also, is it correct to say (around 15:00) that setting @Profile("default") and not including any @Profile annotation in a bean are equivalent? I believe that no @Profile = "always present", while @Profile("default") = "present only when no explicit profile is given".
useful skills, thank you
Thanking you Guru ji.....🤝🤝
Super excellent..
what about if we are creating War or EAR and deploying to Different Env, how I will choose profile there.
Amazing ❤
What if you can't specify the profile in command line arguments because you have to deploy the .war in an environment such as Jboss? thanks
Question: Lets say you have a bean called Repository( in source code with active profile "production") in source code , in test (folder, for functional tests) having another Bean called Repository( to connect embedded H2 instead of actual DB) with active profile as "test" , when we run application will test bean will be injected to container? (It does not worked for me)
What's the order of profile in ur application file??
@@ayushgupta8239 - we are running test base class with with @activeprofile as test, qq: will spring context will consider Repository bean which is in src/test/jav?
@@haribachala i don't think so
What happened if we have @profile("dev") & @profile("production") and we not activated dev or production profile than which bean should be initiated.
Default
I needed a bean for an integration test. I didn't use a profile annotation so it was instantiated via the default profile. I could see that in the log. However, I got no bean found when autowiring it into my integration test. How can that be when I could see that the bean had been created?
Very useful..feature
is it ok to have no default profile in the aplication and provide it manually for each environment with only the profile name in it? this could protect from running application with a wrong profile
You can, but remember that there’s always a default profile active. So, even if you have one configuration value in your app that’s common across all profiles, it would be silly to duplicate it across all your profiles. Hope that clarifies
great, thank you
You are Awesome Bro You are A Hero You ROCK THE WORLD BRO YOU ARE SUPER AND THE BEST
The video number is wrong. It should be [08]
Thanks! Fixed.
nice, thanks sir
Perfect!
how come you know so much about this thing, dude?
i added this property on application-test.yml file
spring.profiles.active: test
Still it load the default profile.
i am using the spring boot v2.2.4.RELEASE.
is there any more change to do ?
i guess you need to add
spring.profiles.active: test
to
application.yml
and NOT
application-test.yml
@@bikramnarayankundu2924 Suppose i have three version of the profile.
1. Dev
2. QA
3. PROD
i need to keep three separate files for the three env, correct me if i am wrong.
so in that case, based on the requirement, we will add the "spring.profiles.active: test" i the file name application-test.yml
as per the naming convention.. application-.yml
eg:: application-test.yml, applciation-dev.yml, application-prod.yml
@@bishwajitvikram3794 I guess this is wrong...
1. Have all the files
2. Just change the application.yml file with the property spring.profiles.active: Dev
Or spring.profiles.active: QA
Or spring.profiles.active: PROD
@@bikramnarayankundu2924 Thanks a lot Bikram ! It worked. I git it all wrong. BTW, it working correctly.
Where i can find your code . how you can define Map value in yaml file?
Wonderful ❣️
Sir how we run spring boot test from command line with profiles ?
-Dspring.profiles.active=
Awesome
Thank you so much
Spring docs are garbage, man. Fortunately, there is Java Brains to save the day
Note - 11:34
Awesome tutorial! Thanks for putting this up!
One confusion I still have is, you mention about having multiple configurations (as a result of multiple profiles) in one jar file at ua-cam.com/video/P91tqdWUHE4/v-deo.html.
But wouldn't it be ideal to separate out config from the jar files similar to ua-cam.com/video/P91tqdWUHE4/v-deo.html because configs have a different lifecycle than the application itself. For instance, I do not need to release a new version of a jar for a config change.
yes but you can override configs from environment variables.
so for minor change you dont have to release the app.
yhooooo
Better have full screen. No value showing up you
The density of information is very low. So much blah blah. Anyway, thanks for such video