[英]External properties Spring boot
我正在尝试让我的spring boot项目使用在项目外部定义的属性。 我已经尝试了文档中介绍的步骤,但是无法正常工作。
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
.
+- folder
+- properties
+- application.properties
+- myproject
+- src
我将此选项用于VM选项: -Dspring.config.location=file:../properties/
但不起作用。 我尝试了spring.config.location
多个值, spring.config.location
均未成功(我想问题出在这里)。
假设我有一个连接到Postgresql数据库的应用程序。 我的数据库连接详细信息不在项目的某个集中版本控制系统中。 我在我的应用程序中使用bootstrap.properties
文件。 我已经在bootstrap.properties
配置为在应用启动时获取我的数据库连接详细信息。 例如,
postgresql.database.url:${databaseUrl}
postgresql.database.username:${databaseUsername}
postgresql.database.password:${databasePassword}
我将配置键作为bootstrap.properties中的值传递。 在应用运行时,它将根据密钥获取相应的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.