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

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ม.ค. 2023
  • 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: th-cam.com/users/CodeDecode?...
    LinkedIn : / codedecodeyoutube
    Instagram: / codedecode25
    #springboot #springbootprofile #codedecode

ความคิดเห็น • 45

  • @PJ-oz2pg
    @PJ-oz2pg ปีที่แล้ว +1

    Thanks for sharing the knowledge. Its very helpful.

  • @devmantras5587
    @devmantras5587 3 หลายเดือนก่อน +1

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

    • @CodeDecode
      @CodeDecode  3 หลายเดือนก่อน +1

      😊👍

  • @NMK255
    @NMK255 5 หลายเดือนก่อน +1

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

    • @CodeDecode
      @CodeDecode  5 หลายเดือนก่อน

      Thanks 😊

  • @LuminalLife2808
    @LuminalLife2808 ปีที่แล้ว +1

    awesome, cleared lot of concepts

  • @zabhashdamha
    @zabhashdamha ปีที่แล้ว +1

    Superb. Simple and crisp 👍

  • @varunb2453
    @varunb2453 ปีที่แล้ว

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

  • @Ashibha
    @Ashibha ปีที่แล้ว

    Please make series on gemfire implementation

  • @santosh0513
    @santosh0513 ปีที่แล้ว +1

    Teaching skill is simple and super, thank you 😊

    • @CodeDecode
      @CodeDecode  ปีที่แล้ว

      Thanks Santosh 🙂🙂

  • @ruchajoshi1517
    @ruchajoshi1517 ปีที่แล้ว +1

    Good explanation

  • @techieadi4377
    @techieadi4377 5 หลายเดือนก่อน

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

  • @lunatichigh2896
    @lunatichigh2896 10 หลายเดือนก่อน +1

    Thank you

    • @CodeDecode
      @CodeDecode  10 หลายเดือนก่อน

      You're welcome

  • @NikhilR07
    @NikhilR07 ปีที่แล้ว +1

    Nice video ☺️

  • @sheikh_mohd_Uzair
    @sheikh_mohd_Uzair ปีที่แล้ว +2

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

  • @arpitsik4649
    @arpitsik4649 ปีที่แล้ว +1

    💯❤️

  • @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

  • @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
      th-cam.com/video/25IPuO_8hxg/w-d-xo.html

  • @balakrishnasoftware2666
    @balakrishnasoftware2666 5 หลายเดือนก่อน +1

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

    • @CodeDecode
      @CodeDecode  5 หลายเดือนก่อน

      Sure 👍

  • @user-ht1iv5mu3i
    @user-ht1iv5mu3i 8 หลายเดือนก่อน

    Hi, I have created the same demo, but message is not printing, just showing as started SpringBootApplicaiton, no error. how to debug?

  • @padmapriya6880
    @padmapriya6880 ปีที่แล้ว +1

    Hi, please do file handling concept for interview preparation

  • @kids-plays
    @kids-plays ปีที่แล้ว +1

    Don't add ads in between

  • @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🙂

  • @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