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

Поделиться
HTML-код
  • Опубликовано: 30 сен 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

  • @balakrishnasoftware2666
    @balakrishnasoftware2666 8 месяцев назад +1

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

  • @kids-plays
    @kids-plays Год назад +1

    Don't add ads in between

  • @sheikh_mohd_Uzair
    @sheikh_mohd_Uzair Год назад +2

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

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

  • @PJ-oz2pg
    @PJ-oz2pg Год назад +1

    Thanks for sharing the knowledge. Its very helpful.

  • @NMK255
    @NMK255 8 месяцев назад +1

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

  • @techieadi4377
    @techieadi4377 7 месяцев назад

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

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

  • @devmantras5587
    @devmantras5587 6 месяцев назад +1

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

  • @varunb2453
    @varunb2453 Год назад

    Hi, Can you please create videos on spring could config and shows us with different environments with it.. 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
      ruclips.net/video/25IPuO_8hxg/видео.html

  • @ruchajoshi1517
    @ruchajoshi1517 Год назад +1

    Good explanation

  • @arpitsik4649
    @arpitsik4649 Год назад +1

    💯❤️

  • @lunatichigh2896
    @lunatichigh2896 Год назад +1

    Thank you

  • @LuminalLife2808
    @LuminalLife2808 Год назад +1

    awesome, cleared lot of concepts

  • @Ashibha
    @Ashibha Год назад

    Please make series on gemfire implementation

  • @zabhashdamha
    @zabhashdamha Год назад +1

    Superb. Simple and crisp 👍

  • @NikhilR07
    @NikhilR07 Год назад +1

    Nice video ☺️

  • @padmapriya6880
    @padmapriya6880 Год назад +1

    Hi, please do file handling concept for interview preparation

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

  • @santosh0513
    @santosh0513 Год назад +1

    Teaching skill is simple and super, thank you 😊