简体   繁体   English

spring-boot中如何使用环境变量

[英]How to use environment variables in spring-boot

I want to load properties from external file present under my home directory.我想从我的主目录下的外部文件加载属性。 I set a environment variable using the file as follows我使用该文件设置了一个环境变量,如下所示

export ENV_HOME=/home/usr/environment.properties

I want to use the properties present in environemnt.properties files in spring-boot application.我想在 spring-boot 应用程序中使用 environemnt.properties 文件中存在的属性。 I don't want to include this in packed jar我不想把这个放在包装好的罐子里

How to achieve this?如何实现这一目标?

在控制器中使用 @PropertySource("${ENV_HOME}") 将覆盖来自外部文件的属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 spring-boot application.properties中的环境变量错误 - Environment Variables in spring-boot application.properties error application.properties 中电子邮件数据中 Spring-Boot 中的环境变量 - environment variables in Spring-Boot in email data in application.properties 通过 Spring-boot 中的 REST 端点读取环境变量值 - Reading environment variables values through a REST endpoint in Spring-boot 如何使用 MockMVC 对 Spring-Boot REST 端点进行单元测试,其中路径映射是环境变量? - How to Unit test Spring-Boot REST endpoints with MockMVC where the path mappings are environment variables? 在 spring-boot 应用程序中使用 Ascii 字符串作为环境变量的值 - Use Ascii string as value of a environment variable in spring-boot app 如何在spring-boot中使用2个或更多jdbcTemplate? - How to use 2 or more jdbcTemplate with spring-boot? 如何在 spring 引导中使用带有 application.properties 的环境变量? - How to use environment variables with application.properties in spring boot? 根据系统环境变量加载Spring-Boot application.yaml文件 - Load Spring-Boot application.yaml file based on system environment variables 网址中的 Spring-boot 位置变量 - Spring-boot location variables in urls 如何使用jdeps分析胖子罐的依赖关系(spring-boot)? - How to use jdeps to analysis dependency of a fat jar(spring-boot)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM