[英]How do I set Spring Boot environment variables in Upstart to override application.properties?
I have a Spring Boot project that has a series of configuration variables in application.properties. 我有一个Spring Boot项目,在application.properties中有一系列配置变量。 For example: 例如:
server.ssl.enabled = false
server.port = 8080
I would like to move these variables into an upstart script, where they will be loaded into environment variables and override the contents of the application.properties file. 我想将这些变量移到新贵的脚本中,在其中将它们加载到环境变量中并覆盖application.properties文件的内容。
This is my attempt to load these in the upstart conf file: 这是我尝试将它们加载到upstart conf文件中:
env server.ssl.enabled=false
env server.port=8080
The init-checkconf /etc/init/my-example.conf
utility to check the upstart configuration file produces the following error, with the first error on the line for server.ssl.enabled
: ERROR: File /etc/init/my-example.conf: syntax invalid: init:my-example.conf:15: Unexpected token
用于检查启动配置文件的init-checkconf /etc/init/my-example.conf
实用程序会产生以下错误,其中server.ssl.enabled
行上的第一个错误是: ERROR: File /etc/init/my-example.conf: syntax invalid: init:my-example.conf:15: Unexpected token
What is the proper syntax to set these variables in upstart, with the names used in the application.properties file? 在upstart中使用application.properties文件中使用的名称设置这些变量的正确语法是什么? All of the upstart examples I have found use names that do not include the character .
我发现的所有新贵示例都使用不包含字符的名称.
. 。
Replace the dots in the property names with underscores. 用下划线替换属性名称中的点。 Spring Boot will cover it for you. Spring Boot将为您提供帮助。 Case doesn't matter. 大小写无关紧要。
You can also pass the properties as command line arguments such as: 您还可以将属性作为命令行参数传递,例如:
$ java -jar app.jar --foo.bar="splat"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.