Spring Boot Secret Properties: How to store secrets in your Configuration Properties

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ส.ค. 2024
  • In this tutorial, you will learn how to use Spring Boot secret properties in your next application. When you define your own configuration properties you need to find a way to set secret properties. You can do this through command-line arguments or environment variables, but I often forget that they are there.
    Spring Boot 2.4 gave us the ability to import additional configuration files. In this demo, you will set the secret values in a file called secret.properties and ignore it from Git, so it doesn't get checked in. To wrap this up I will show you how to deploy this project to Heroku and override those secret properties using config vars.
    🔗Resources & Links mentioned in this video:
    Github Repo: github.com/dan...
    👋🏻Connect with me:
    Website: www.danvega.dev
    Twitter: / therealdanvega
    Github: github.com/dan...
    LinkedIn: / danvega
    Newsletter: www.danvega.de...
    SUBSCRIBE TO MY CHANNEL: bit.ly/2re4GH0 ❤️

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

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

    Be aware that unless you take certain steps, if you build your archive from IDE your secrets.yml file will be packaged in the final application archive.

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

      thank you so much for this comment, there is a huge chance I wouldn't notice if not for your comment

    • @apexyu164
      @apexyu164 2 หลายเดือนก่อน

      which step need to be taken

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

    This was super helpful. I have been looking for a way to have .env files within Java and Spring boot. Coming from javascript as well its sooo easy. But you have made it so easy on this language as well. Thank You!

  • @SouravBanik90
    @SouravBanik90 11 หลายเดือนก่อน +1

    Thanks a ton! This is helpful! I really did not know how to deploy in production as a personal project. This gives me new horizons to explore and learn!

    • @DanVega
      @DanVega  11 หลายเดือนก่อน +1

      Glad it helped!

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

    Super helpful, thanks for showing the production method, cleared all my doubts ❤

  • @Mexa1482
    @Mexa1482 ปีที่แล้ว +4

    Great video!! Been looking for this and by far the best explanation.

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

      Glad it was helpful!

  • @drakenra
    @drakenra 9 หลายเดือนก่อน

    This is great! Didn't know that such thing exists before this. I have just create new profile application file and put git ignore that file or pass those variables as environment variable 😅

  • @mostafahashemi9073
    @mostafahashemi9073 6 หลายเดือนก่อน

    Thank you 🎉🎉.
    in our team with the help of spring-config-location , its operation group that would put config file near jars .
    We never have operational environment config during coding . Imo its not good practice.

  • @AnantaAkash.Podder
    @AnantaAkash.Podder 6 หลายเดือนก่อน

    Great video sir... was searching for this kind of mechanism... Thank you Sir

  • @amarildo-xyz
    @amarildo-xyz 2 ปีที่แล้ว +2

    Previously I just created a prod profile, set it as active before creating the jar, or add it to the command line args on production. If I didn't want to make those configs/credentials public, just ignored the prod file in gitignore
    Including properties files is quite a nice addition, I might even use this to organize configurations in different files

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

    as always great content, can you please in the future make videos about testing integration and e2e pleasee, and please we need more content

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

    That was crazy helpful! Thanks a lot

    • @DanVega
      @DanVega  2 ปีที่แล้ว

      Glad it helped!

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

    Hi!, nice video, it was useful for me, but I want to know if you have a similiar video where explain how to convert aws secrets in a configuration properties to use. Thanks

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

    Hi, this is really gold, thank you
    Thank you

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

      Thank you too!

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

    Can you show us the vault integration?

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

    saved my day, thanks alot

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

      You're welcome!

  • @WondervilleSeries
    @WondervilleSeries 4 หลายเดือนก่อน

    Thank you!

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

    This is a great tutorial. Learnt a lot from this. Thanks a lot.
    One curious question: From where did you get this animated picture of your face? I want to generate too :) Can you share the link please?

  • @bpnaidu4u
    @bpnaidu4u 11 หลายเดือนก่อน

    @Dan Vega
    Thank you for wonderful Video on Spring boot secrets with Java 17 version,
    Could you help me how can we do same example for Java 8 version where we do not have record type is not present

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

    Big thumbs up!

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

    Thank you a lot!!!

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

    Thank you so much!

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

    very usefull, thanks you

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

    How to solve my Java With Maven CI build fail because it can't resolve those variables?

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

    If you have multiple devs working on the project how do you set them up with all of the secrets? Doesn't it become unmanageable?

  • @tree2rhym
    @tree2rhym 2 ปีที่แล้ว

    Basically if I do the same with aws/azure cloud provider , I just need to make sure to have those properties in env , is that understanding correct ?

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

    Yes I want to go with you

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

    is it possible to use classpath: or file: besides that optional: option?

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

      You can use classpath or file to locate a file but optional is used to tell Spring not to fall over if its not found.

  • @yelderiny
    @yelderiny 2 ปีที่แล้ว

    How do you deal with Github workflows not working after doing this?

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

    fire🔥

  • @jamesokonkwo5815
    @jamesokonkwo5815 2 ปีที่แล้ว

    My spring.config.import=optional:secrets.properties is not importing, not working. Is not seeing it, returns NullException and pointing at the main class where I declare (map) the configuration properties. How can I resolve it please?

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

      Check spring boot version. I think spring.config.import is only since like 2.4.0 or smth.

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

    Thanks for the video, what about the case when we build a Docker image ? In real life, our DevOps "Philosophy" regarding containers, is to build and image independently from the environment (DEV, UAT or PROD) and to add the config (with secrets) later when deploying.

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

      You can set an environment variable in docker, you're just overriding that.

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

    why not use jasypt?

  • @dd1.d
    @dd1.d 2 ปีที่แล้ว +1

    I use Jasypt to encrypt these secrets

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

      Where do you store jasypt encrypt/decrypt key?