0

I am trying to externalize the properties file of my project.

Steps to run:

  1. Created a jar file without properties file.
  2. Run these script file from command prompt.

.

java -jar read-apis.jar --spring.config.location=classpath:..\config\application.properties,classpath:..\config\sql-config.properties,classpath:..\config\error-config.properties,classpath:..\config\messgae-config.properties,classpath:..\config\validation-config.properties

OR

java -cp ..\config\application.properties, -cp ..\config\sql-config.properties, -cp ..\config\error-config.properties, -cp ..\config\messgae-config.properties, -cp ..\config\validation-config.properties -jar read-apis.jar

Its not working for me please help me.

serenesat
  • 4,611
  • 10
  • 37
  • 53
user3352615
  • 119
  • 2
  • 5
  • 13
  • You cant externalize like this ... spring.config.location will only load one application.properties file or any other "name".properties file("name" specified using spring.config.name). Thats the way spring boot was designed. If you need to externalize all other property files as well you need to implement your logic. Refer the *second answer* http://stackoverflow.com/questions/25855795/spring-boot-and-multiple-external-configuration-files. – ArunM Jul 08 '15 at 19:43
  • you can do like this : java -Dspring.config.location=application.properties,sql-config.properties,error-config.properties -jar read-api.jar – user3352615 Jul 14 '15 at 00:13

2 Answers2

0

I am basing information from the Spring Boot documentation here and my own experience. From what I can tell you have a configuration directory at ../config. You can either:

  • Put the config directory at the location where you run the application from. If the config directory is located at . instead of .. it will be picked up without any additional parameters.
  • OR leave it there and use something similar to your first form like this: "spring.config.location=file:..\config\application.properties". Since it is not in the jar you will need to use "file" instead of "classpath".

Give that a try and see if it works. It looks like you are trying to put multiple files in the search list. It may work but I am not certain. If that is the case then the first bullet above may not work since only application.properties would be searched for in the config directory. You could always add the other files in using the config property since it looks like it always uses the default paths also.

Rob Baily
  • 2,770
  • 17
  • 26
0

java -Dspring.config.location=application.properties,sql-config.properties,error-config.properties -jar read-api.jar

This works out for me.

user3352615
  • 119
  • 2
  • 5
  • 13