-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Document the use of --args to pass arguments to bootRun #1176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's the same as "gradle run". Do we want to change that? |
shouldn't we look at the maven plugin as well? |
Yes, it's the same thing really (spring-boot:run is a lot like exec:java). |
This was something @tomaslin mentioned to me. Not sure what the answer is yet, I just wanted to note that is was a pain point. |
To add a little bit more context, if you read the spring boot documentation, you think that you would be able to pass in command line arguments to bootRun to take advantage of SpringApplication's ability to access them as a property. However, doing something like
doesn't seem to work, since gradle needs you to explicitly bind the parameters you need. If you look at the grails-gradle integration, Jon Engelman bypasses this by sending the parameters passed into the grailsArgs environment variable into the application,
It is quite tedious to have to change the build.gradle file for every environment variable, and it would be nice if the plugin allowed a mechanism to send command line parameters into the launcher |
For the record, the maven plugin already supports that (kinda). You can run something like this
This would add a "foo" property to the
This is not coming out of nowhere, the I think it would be nice to add a specific property there to be be able to specify the profiles to enable for the app. |
This commit adds an additional property to the run goal of the maven plugin that allows to specify the profile(s) to activate. Those can be set on the command line in a convenient way. For instance, this would enable the prod and foo profiles: mvn spring-boot:run -Drun.profiles=prod,foo Relates to spring-projectsgh-1176
+1 |
The updated plugin in spring boot 2.0 has broken my workaround for starting app with a profile selected at runtime:
I can't for the life of me figure out how to accomplish this with the new plugin. Any suggestions? |
It's also worth noting that this may change, i.e. |
Thanks @wilkinsona - as an FYI this is what i ended up doing:
|
@wilkinsona The M6 docs you linked to say:
However, I couldn't find any examples of those properties' usage, neither could I find any reference to those in the RC1 docs. |
As anticipated things changed in #10872. |
@wilkinsona I think this (and #832) should be reopened. |
@behrangsa This issue is still open and will address #832. |
Since gradle 4.9, it's possible to pass argument to a JavaExec task (which bootRun is) using the following syntax:
Note however that, on macOS with zsh at least, trying to use that syntax to pass a profile makes the build fail immediately:
However, simply adding a space before the
This should hopefully help people like me who tried making that work for half an hour :-) |
Thank you, @jnizet. Bash also requires a space before the |
It works without a space if you use
|
I've opened gradle/gradle#6644. We can probably proceed with documenting this and then updating the documentation if the Gradle issue is addressed. |
I've solve it as follows, if anyone is interested: |
Double check how easy it is to pass arguments to a
bootRun
application and how profiles can be activated.The text was updated successfully, but these errors were encountered: