且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Spring Boot 应用程序中设置系统属性

更新时间:2022-04-08 08:17:10

从 Java 代码内部设置系统变量不是一个好主意.基本上,变量是为了让代码没有任何变量值.

Not good idea to set system variables from inside Java code. Basically, variables are meant to keep the code free from having any variable values.

使用属性文件来存储您的配置.Spring Boot 在外部化您的配置方面做得很好.它还可以让您在单独的文件中进行环境配置,并在初始化方面做得很好.

Use properties files to store your configurations. Spring Boot does a great job externalising your configurations. It also let to you have environmental configurations in separate files and does a great job initialising it.

参考https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html