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

Поділитися
Вставка
  • Опубліковано 8 жов 2024
  • 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/u...
    Course Description Video :
    yt.openinapp.c...
    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: www.youtube.co...
    LinkedIn : / codedecodeyoutube
    Instagram: / codedecode25
    #springboot #springbootprofile #codedecode

КОМЕНТАРІ • 45

  • @NMK255
    @NMK255 8 місяців тому +1

    Very crisp and clear. Thank you so much ❤ keep rocking🎉

  • @devmantras5587
    @devmantras5587 6 місяців тому +1

    Wow, all thing at one place. Thanks a lot.

  • @PJ-oz2pg
    @PJ-oz2pg Рік тому +1

    Thanks for sharing the knowledge. Its very helpful.

  • @techieadi4377
    @techieadi4377 7 місяців тому

    bravo , they have ask me the same question if QA has two data base property how you can define

  • @santosh0513
    @santosh0513 Рік тому +1

    Teaching skill is simple and super, thank you 😊

  • @zabhashdamha
    @zabhashdamha Рік тому +1

    Superb. Simple and crisp 👍

  • @LuminalLife2808
    @LuminalLife2808 Рік тому +1

    awesome, cleared lot of concepts

  • @ruchajoshi1517
    @ruchajoshi1517 Рік тому +1

    Good explanation

  • @balakrishnasoftware2666
    @balakrishnasoftware2666 8 місяців тому +1

    Can you please make video for connecting with multiple database in spring boot

  • @sheikh_mohd_Uzair
    @sheikh_mohd_Uzair Рік тому +2

    Create video on unit testing for service layer and controller using TDD(test driven development).

  • @varunb2453
    @varunb2453 Рік тому

    Hi, Can you please create videos on spring could config and shows us with different environments with it.. thank you

  • @lunatichigh2896
    @lunatichigh2896 Рік тому +1

    Thank you

  • @amitnilajkar6272
    @amitnilajkar6272 Рік тому +1

    make a nice video on dynamic forms where u connect from nosql. just basic is enough

    • @CodeDecode
      @CodeDecode  Рік тому +1

      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
      ua-cam.com/video/25IPuO_8hxg/v-deo.html

  • @Ashibha
    @Ashibha Рік тому

    Please make series on gemfire implementation

  • @sundaraV-k8l
    @sundaraV-k8l 10 місяців тому

    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

  • @NikhilR07
    @NikhilR07 Рік тому +1

    Nice video ☺️

  • @padmapriya6880
    @padmapriya6880 Рік тому +1

    Hi, please do file handling concept for interview preparation

  • @anilsingh-gt7yd
    @anilsingh-gt7yd Рік тому +1

    Hi.. are there any paid batches also going on?

    • @CodeDecode
      @CodeDecode  Рік тому

      Not yet Anil. Will let you know if there is any🙂

  • @kids-plays
    @kids-plays Рік тому +1

    Don't add ads in between

  • @arpitsik4649
    @arpitsik4649 Рік тому +1

    💯❤️

  • @hamednikbakht9708
    @hamednikbakht9708 Рік тому

    hi please add subtitle

    • @akashyadav-fp7re
      @akashyadav-fp7re Рік тому +2

      try to watch video in laptop you can find transcript in 3 dotted icon. where you can easily get subtitles.

    • @CodeDecode
      @CodeDecode  Рік тому +1

      Thanks Akash👍🙂

    • @hamednikbakht9708
      @hamednikbakht9708 Рік тому +1

      @@akashyadav-fp7re Thankful