Skip to content

Commit 6beb0c9

Browse files
committed
Document how to override plugin configuration on the command line
Closes gh-21536
1 parent b210d06 commit 6beb0c9

File tree

1 file changed

+42
-0
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc

1 file changed

+42
-0
lines changed

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/using.adoc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,45 @@ For instance, to use a different version of the SLF4J library and the Spring Dat
106106
----
107107

108108

109+
110+
[[using-overriding-command-line]]
111+
=== Overriding settings on the command-line
112+
The plugin offers a number of user properties, starting with `spring-boot`, to let you customize the configuration from the command-line.
113+
114+
For instance, you could tune the profiles to enable when running the application as follows:
115+
116+
[indent=0]
117+
----
118+
$ mvn spring-boot:run -Dspring-boot.run.profiles=dev,local
119+
----
120+
121+
If you want to both have a default while allowing it to be overridden on the command-line, you should use a combination of a user-provided project property and MOJO configuration.
122+
123+
[source,xml,indent=0,subs="verbatim,attributes"]
124+
----
125+
<project>
126+
<properties>
127+
<app.profiles>local,dev</app.profiles>
128+
</properties>
129+
<build>
130+
<plugins>
131+
<plugin>
132+
<groupId>org.springframework.boot</groupId>
133+
<artifactId>spring-boot-maven-plugin</artifactId>
134+
<version>{gradle-project-version}</version>
135+
<configuration>
136+
<profiles>${app.profiles}</profiles>
137+
</configuration>
138+
</plugin>
139+
</plugins>
140+
</build>
141+
</project>
142+
----
143+
144+
The above makes sure that `local` and `dev` are enabled by default.
145+
Now a dedicated property has been exposed, this can be overridden on the command-line as well:
146+
147+
[indent=0]
148+
----
149+
$ mvn spring-boot:run -Dapp.profiles=test
150+
----

0 commit comments

Comments
 (0)