how to pass application.properties in commandLine for a spring boot application?

感情迁移 提交于 2019-12-03 13:35:59

问题


I have a spring boot application and I want to pass application.properties file in commandLine when I start-up.

i.e when I run mvn spring-boot:run --application.properties

I will have a default application.properties in src/main/resources. but that is only for testing purposes. In the production run, I would like to pass the property file in commandLine.

I am aware of passing single arguments such as

mvn spring-boot:run --server.port=9001.

But I have many such properties and would prefer to pass a property file if that is possible.


回答1:


You can do that with spring.config.location property:

mvn spring-boot:run -Dspring.config.location=your.properties


来源:https://stackoverflow.com/questions/31819300/how-to-pass-application-properties-in-commandline-for-a-spring-boot-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!