Read environment variable in SpringBoot

前端 未结 4 2154
遇见更好的自我
遇见更好的自我 2020-12-15 16:15

What is the best way to read environment variables in SpringBoot?
In Java I did it using:

String foo = System.getenv(\"         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 17:12

    Alternatively, you can use the org.springframework.core.env.Environment interface to access environment variables:

    @Autowired
    private Environment env;
    
    ...
    
    System.out.println(env.getProperty("bar"));
    

    Read more...

提交回复
热议问题