简体   繁体   English

如何在Upstart中设置Spring Boot环境变量以覆盖application.properties?

[英]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.

相关问题 如何以编程方式覆盖 Spring Boot application.properties? - How can I override Spring Boot application.properties programmatically? 如何在 Spring Boot 应用程序的 application.properties 文件中设置 MyBatis 配置属性? - How do I set MyBatis configuration properties in an application.properties file in a Spring Boot application? spring-boot application.properties中的环境变量错误 - Environment Variables in spring-boot application.properties error 根据环境变量设置Spring Boot application.properties - Set Spring Boot application.properties based on Environment Variable 如何在 spring boot application.properties 文件中设置 mybatis 属性? - How do I set a mybatis property in spring boot application.properties file? 如何在 Spring-Boot 的生产过程中覆盖 application.properties? - How to override application.properties during production in Spring-Boot? 如何在Spring Boot集成测试中覆盖application.properties? - How to override application.properties in Spring Boot integration test? Spring启动 - Application.properties中的自定义变量 - Spring boot - custom variables in Application.properties Spring Boot:如何在 application.properties 中指定带有破折号的环境变量? - Spring Boot: How do you specify an environment variable that has dashes in the application.properties? 使用外部属性覆盖 spring-boot application.properties - Override spring-boot application.properties with external properties
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM