Most wrongly answered Question Spring boot | Spring boot profiles Interview Questions | Code Decode

  Рет қаралды 28,355

Code Decode

Code Decode

Жыл бұрын

Spring boot profile management for different environment is a very important spring boot interview question.
Udemy Course of Code Decode on Microservice k8s AWS CICD link:
openinapp.co/udemycourse
Course Description Video :
yt.openinapp.co/dmjvd
We have demostrate it in every possible way. Please watch this video till very end so that you'll get best out of it.
App store link nxtlvl.in/w2o
Play store link nxtlvl.in/qlx
How do you segregate your environment specific properties in Spring Boot?
Spring Profiles provide a way to segregate parts of your application configuration and make it only available in certain environments.
Example : how to configure different databases at runtime based on the specific environment by their respective profiles. As the DB connection is better to be kept in a property file, it remains external to an application and can be changed.
How To create profiles in Spring boot?
Spring Boot - by default - provides just one property file ( application.properties).
So, how will we segregate the properties based on the environment?
The solution would be to create more property files and add the "profile" name as the suffix and configure Spring Boot to pick the appropriate properties based on the profile. For example :
The application.properties will remain as a master properties file, but if we override any key in the profile-specific file, the latter will gain precedence.
How To Pick specific profile like Dev in Spring boot?
Spring only acts on a profile if it’s activated. Let’s look at the different ways to activate a profile.
The default profile is always active. Spring Boot loads all properties in application.properties into the default profile. We could rename the configuration file to application-default.properties and it would work the same.
This profile is a fallback property file. This means that if a property is defined in the default profile, but not in the foo profile, the property value will be populated from the default profile. This is very handy for defining default values that are valid across all profiles.
To activate other profiles than the default profile, we have to let Spring know which profiles we want to activate.
spring.profiles.active=dev
-Dspring.profiles.active=dev
SpringApplication application = new SpringApplication(.class)
SpringApplication.setAdditionalProfiles("dev");
application.run(args);
Multiple sources too can be active using -
spring.profiles.active=prod, dev
-Dspring.profiles.active=prod,dev
If common properties are there in both then last one will override - here Dev will override
How Can we configure A bean to be created only in a certain Profile?
With profiles, we can also control which beans are loaded into Spring’s application context.
@Component
@Profile("Test")
class TestBean {
This bean will automatically be picked up by Spring Boot’s classpath scan because we used the @Component annotation.
The bean will not be instantiated and not be added to the application context if profile is not Test.
Use Profile-Specific Beans Responsibly!
Adding certain beans to the application context for one profile, but not for another, can quickly add complexity in application! We always have to pause and think if a bean is available in a particular profile or not, otherwise, this may cause NoSuchBeanDefinitionExceptions when other beans depend on it!
What is @Profile Annotation used for?
@Profile annotation associates a bean to a particular profile
The @Profile annotation simply takes the names of one or multiple profiles.
Ex: We need a bean that should only be active during development, but not production
@Profile("!dev")
@Component
What is @PropertySource Annotation used for?

Most Asked Core Java Interview Questions and Answers: • Core Java frequently a...
Advance Java Interview Questions and Answers: • Advance Java Interview...
Java 8 Interview Questions and Answers: • Java 8 Interview Quest...
Hibernate Interview Questions and Answers:
• Hibernate Interview Qu...
Spring Boot Interview Questions and Answers:
• Advance Java Interview...
Angular Playlist: • Angular Course Introdu...
SQL Playlist: • SQL Interview Question...
GIT: • GIT
Subscriber and Follow Code Decode
Subscriber Code Decode: kzbin.info?...
LinkedIn : / codedecodeyoutube
Instagram: / codedecode25
#springboot #springbootprofile #codedecode

Пікірлер: 45
@NMK255
@NMK255 4 ай бұрын
Very crisp and clear. Thank you so much ❤ keep rocking🎉
@CodeDecode
@CodeDecode 4 ай бұрын
Thanks 😊
@PJ-oz2pg
@PJ-oz2pg 11 ай бұрын
Thanks for sharing the knowledge. Its very helpful.
@CodeDecode
@CodeDecode 11 ай бұрын
Thanks 😊👍
@devmantras5587
@devmantras5587 2 ай бұрын
Wow, all thing at one place. Thanks a lot.
@CodeDecode
@CodeDecode 2 ай бұрын
😊👍
@varunb2453
@varunb2453 Жыл бұрын
Hi, Can you please create videos on spring could config and shows us with different environments with it.. thank you
@zabhashdamha
@zabhashdamha Жыл бұрын
Superb. Simple and crisp 👍
@CodeDecode
@CodeDecode Жыл бұрын
Thanks 🙂🙂
@techieadi4377
@techieadi4377 4 ай бұрын
bravo , they have ask me the same question if QA has two data base property how you can define
@LuminalLife2808
@LuminalLife2808 Жыл бұрын
awesome, cleared lot of concepts
@CodeDecode
@CodeDecode Жыл бұрын
thanks
@Ashibha
@Ashibha Жыл бұрын
Please make series on gemfire implementation
@santosh0513
@santosh0513 Жыл бұрын
Teaching skill is simple and super, thank you 😊
@CodeDecode
@CodeDecode Жыл бұрын
Thanks Santosh 🙂🙂
@lunatichigh2896
@lunatichigh2896 9 ай бұрын
Thank you
@CodeDecode
@CodeDecode 9 ай бұрын
You're welcome
@ruchajoshi1517
@ruchajoshi1517 Жыл бұрын
Good explanation
@CodeDecode
@CodeDecode Жыл бұрын
Thanks
@balakrishnasoftware2666
@balakrishnasoftware2666 4 ай бұрын
Can you please make video for connecting with multiple database in spring boot
@CodeDecode
@CodeDecode 4 ай бұрын
Sure 👍
@sheikh_mohd_Uzair
@sheikh_mohd_Uzair Жыл бұрын
Create video on unit testing for service layer and controller using TDD(test driven development).
@CodeDecode
@CodeDecode Жыл бұрын
Sure we will create it soon
@gayatrideshpande5456
@gayatrideshpande5456 5 ай бұрын
Plz create it
@kids-plays
@kids-plays Жыл бұрын
Don't add ads in between
@NikhilR07
@NikhilR07 Жыл бұрын
Nice video ☺️
@CodeDecode
@CodeDecode Жыл бұрын
Thanks nikhil
@amitnilajkar6272
@amitnilajkar6272 Жыл бұрын
make a nice video on dynamic forms where u connect from nosql. just basic is enough
@CodeDecode
@CodeDecode Жыл бұрын
Ui + backend?
@amitnilajkar6272
@amitnilajkar6272 Жыл бұрын
@@CodeDecode dynamic forms ( standalone components), nodejs , loading controls from mongodb (like metadata form structure ). something like that. great videos you have done very clear logical flow explanation.
@amitnilajkar6272
@amitnilajkar6272 Жыл бұрын
@@CodeDecode u can check this video where he is loading from json files as http cors... i think mongodb nobody has done much n it will be unique. check this link kzbin.info/www/bejne/aGasgaiFlJ2brsk
@padmapriya6880
@padmapriya6880 Жыл бұрын
Hi, please do file handling concept for interview preparation
@praveenn7001
@praveenn7001 Жыл бұрын
❤❤❤
@praveenn7001
@praveenn7001 Жыл бұрын
❤❤❤
@praveenn7001
@praveenn7001 Жыл бұрын
❤❤
@user-ht1iv5mu3i
@user-ht1iv5mu3i 7 ай бұрын
Hi, I have created the same demo, but message is not printing, just showing as started SpringBootApplicaiton, no error. how to debug?
@gattemvenkatvijay
@gattemvenkatvijay Жыл бұрын
Q: How will find a particular controller in a spring boot application.. if I have some 1000s of controller classes.. how to debug?find a easiest solution
@arpitsik4649
@arpitsik4649 Жыл бұрын
💯❤️
@CodeDecode
@CodeDecode Жыл бұрын
🙂🙂
@anilsingh-gt7yd
@anilsingh-gt7yd Жыл бұрын
Hi.. are there any paid batches also going on?
@CodeDecode
@CodeDecode Жыл бұрын
Not yet Anil. Will let you know if there is any🙂
@hamednikbakht9708
@hamednikbakht9708 Жыл бұрын
hi please add subtitle
@akashyadav-fp7re
@akashyadav-fp7re Жыл бұрын
try to watch video in laptop you can find transcript in 3 dotted icon. where you can easily get subtitles.
@CodeDecode
@CodeDecode Жыл бұрын
Thanks Akash👍🙂
@hamednikbakht9708
@hamednikbakht9708 Жыл бұрын
@@akashyadav-fp7re Thankful
I’m just a kid 🥹🥰 LeoNata family #shorts
00:12
LeoNata Family
Рет қаралды 17 МЛН
Дибала против вратаря Легенды
00:33
Mr. Oleynik
Рет қаралды 3,6 МЛН
Sigma Girl Past #funny #sigma #viral
00:20
CRAZY GREAPA
Рет қаралды 24 МЛН
Managing multiple configuration file in Spring Boot in Hindi
8:45
Learn Code With Durgesh
Рет қаралды 32 М.
Spring Tips: Spring Modulith
37:39
SpringDeveloper
Рет қаралды 13 М.
Top 25 Microservice Interview Questions Answered - Java Brains
39:54
I’m just a kid 🥹🥰 LeoNata family #shorts
00:12
LeoNata Family
Рет қаралды 17 МЛН