Passing an entire file to JVM arguments

后端 未结 4 645
别跟我提以往
别跟我提以往 2021-02-04 12:21

I have several systems that all need to load the same properties to the JVM. I can use the -D flag to load one property at a time, but i am looking for something that will load

4条回答
  •  终归单人心
    2021-02-04 12:54

    Some options:

    1. Wrap your properties in your .jar file and then get your processes to read that properties file from getClass().getResourceAsStream()
    2. Write a batch file to execute your Java processes, and either explicitly list the -D options, or create the command line dynamically.

    I solve this problem normally by using Spring (used for other reasons too) and a PropertyPlaceholderConfigurer. That allows me to specify one or more locations for property files and modifies the Spring configuration in-place.

提交回复
热议问题