Hi,
I'm using Spring-boot 1.4.2.RELEASE. My configuration is split in two configuration files (application.yml and configuration.yml). When I launch mvn spring-boot:run from windows (I'm using mobaxterm as emulator) with the following argument, the build failed due to missing configuration keys
mvn -Drun.arguments="--spring.config.location=src/test/resources/app/conf/application.yml,src/test/resources/app/conf/configuration.yml" .... spring-boot:run
Whatever the absolute/relative path. with or without double quotes.
If I append the application.yml with the properties coming from configuration.yml I have no problem.
If I run the following command lines it's ok :
mvn -Dspring.config.location=src/test/resources/app/conf/application.yml,src/test/resources/app/conf/configuration.yml .... spring-boot:run
Or
mvn -Drun.jvmArguments="-Dspring.config.location=src/test/resources/app/conf/application.yml,src/test/resources/app/conf/configuration.yml -Dlogging.config=src/test/resources/app/conf/logback.xml" spring-boot:run
For instant I use the last command line format but I'm expected the run.arguments parameter of spring-boot maven plugin works.
Thanks for your help Regards,
Comment From: snicoll
run.arguments do not require the -- thing (that's the switch to use on the command-line).
Comment From: RaphC
Hi @snicoll
I tried with
mvn -Drun.arguments="spring.config.location=src/test/resources/app/conf/application.yml,src/test/resources/app/conf/configuration.yml" .... spring-boot:run
It doesn't work :(. Seems that spring.config.location is simply not found in this case.
Comment From: snicoll
Sorry but it looks like we're debugging your app and the tracker isn't really meant to do that. Please share a sample that demonstrates that spring.config.location isn't available when you specify it that way.
Comment From: RaphC
Apparently maven (or plexus) add a space after the comma.
DEBUG] Configuring mojo 'org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run' with basic configurator -->
[DEBUG] (f) addResources = false
[DEBUG] (f) agent = []
[DEBUG] (f) arguments = [--spring.config.location=src/test/resources/app/conf/application.yml, src/test/resources/app/conf/configuration.yml]
[DEBUG] (f) classesDirectory = ...\target\classes
[DEBUG] (f) profiles = []
[DEBUG] (f) project = MavenProject: ....:1.7.1-SNAPSHOT @ C...\pom.xml
[DEBUG] (f) skip = false
[DEBUG] (f) useTestClasspath = false
with an other separator (|)
[DEBUG] Configuring mojo 'org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run' with basic configurator -->
[DEBUG] (f) addResources = false
[DEBUG] (f) agent = []
[DEBUG] (f) arguments = [--spring.config.location=src/test/resources/app/conf/application.yml|src/test/resources/app/conf/configuration.yml]
[DEBUG] (f) classesDirectory = ...\target\classes
[DEBUG] (f) profiles = []
[DEBUG] (f) project = MavenProject: ...\pom.xml
[DEBUG] (f) skip = false
[DEBUG] (f) useTestClasspath = false
Comment From: philwebb
It looks like this is a limitation with the way that Maven parses command line arguments. See this question on stackoverflow.com for some background.
I'm not sure that we should attempt to work around this issue ourselves. It may be worth raising it with the Maven developers to see if they could support escaping of commas.
Comment From: RaphC
Thanks @philwebb for the response. Is the documentation of spring-boot-maven-plugin can warn about this limitation?
Is it possible to accept other kind of separator ?
I'll try to see with maven developers how to figure out.
Comment From: snicoll
I am confused. I remember I tested this when I wrote the doc. I'll give it an extra look and update the doc if necessary.
Comment From: snicoll
I've tried again and this work as expected:
mvn -Dspring-boot.run.jvmArguments="-Dspring.config.location=src/test/resources/app/conf/application.yml,src/test/resources/app/conf/configuration.yml" spring-boot:run -X
[DEBUG] JVM argument(s): -Dspring.config.location=src/test/resources/app/conf/application.yml,src/test/resources/app/conf/configuration.yml
Then looking at the property using an application runner it gives me the proper output, i.e. System.out.println("Config location: " + environment.getProperty("spring.config.location")); gives me:
Config location: src/test/resources/app/conf/application.yml,src/test/resources/app/conf/configuration.yml
@RaphC it's been a while but if you have a sample and instructions that reproduce the problem we can reopen and investigate.
Comment From: realFranco
Hello out there, I tried the answer from @snicoll and work for me:
mvn
-Dspring-boot.run.jvmArguments=\
"-Dspring.config.location=src/test/resources/app/conf/application.yml,src/test/resources/app/conf/configuration.yml"\
spring-boot:run -X
For my case I have to include the -gs flag to change the settings.xml, a little of more complexity to the command but in overall work as expected.